samedi 30 janvier 2016

How to use C++ 11's using for template function to remove namespace in a scope

I have a template function:

namespace Example
{
template<class T>
T Foo() { return T(0); };
}

I would like to use a using statement or similar so that I do not have to prefix the function name with it's namespace when calling it i.e.

template<class T> using Foo = Example::Foo<T>;

However this does not work.

I do not want to use this approach as it would include everything form the namespace Example:

using namespace Example;

Is there a nice C++ 11 way to create a shortened alias to a function in a namespace?

Aucun commentaire:

Enregistrer un commentaire