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 the following 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?
As for any symbol, you can do using Example::Foo;
. This can be used either in namespace scope, or in function scope (this is actually present in C++98, it is not new in C++11). The approach you were trying to do works only for types, while Foo
is a function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With