lundi 1 juin 2015

Is it possible to extract array size from a template argument?

If this is a duplicate I apologize. I looked around and found similar issues but nothing exactly like this.

If I instantiate a template like so...

MyClass<int[10]> c;

How can I write the template to get access to both the type and the array size? I've tried everything I can think of and I can't get it.

I was inspired by the std::function template which lets you use similar syntax to the function prototype, like...

std::function<int(MyClass&)> myfunc;

So I thought it would be nice to have something similar for the array and its size. I can use any of the newest c++ features (c++ 11/14).

Aucun commentaire:

Enregistrer un commentaire