mardi 5 mai 2015

How to implement a template function returning a vector from the template argument?

Is there a way (in C++ 11) to implement the following method:

template <typename T>
std::vector<T> makeTypedVector(void* array, int n)
{
    //construct an std::vector of type T from the given array
}

I would share what I've tried but I have no clue on how to implement it :)

Edit:

Is the same method possible for arrays instead of std::vector?

Aucun commentaire:

Enregistrer un commentaire