vendredi 27 février 2015

Can I use an alias for static member function templates?

Using C++11, I'd like to call a static member function template without qualifying it with the scope of its enclosing class:



struct Test {
template<typename T>
static bool Function(T x)
{ /* ... */ }
};

int x;
Test::Function(x); // I don't want to write this
Function(x); // I want to be able to write this instead


I can define another function with the same signature at global scope and forward the arguments, but I'd prefer a solution that doesn't force me to write another function. I'd also like to avoid using a macro.


This question is related: (using alias for static member functions?) but doesn't seem to cover the case of function templates.


Aucun commentaire:

Enregistrer un commentaire