samedi 28 novembre 2015

Full specializtion of a template function for a template return value

Suppose I have a template function like this:

template <typename Key>
Key foo(const string &name);

I know that for specializing a template function we must fully specialize it like this:

template<>
int foo(const string &name);

But now I'm looking for a way to specialize this function for a template object, something like this:

template<>
Bar<Key> foo(const string &name);

I think this would not violate any c++11 laws for specialization and function overriding. But still I could not find a way to do this.

I prefer to do not use a class instead a function to able to make partial specialization for implementing this functionality. Do you have any suggestion to implement this function and specialize it for a template return value?

Aucun commentaire:

Enregistrer un commentaire