Reputation: 105
This is OK:
template<typename T>
using MyVector = std::vector<T>;
MyVector<int> xyz;
But not this:
template <typename F>
using MyCalc = float calc1(F f) { return -1.0f * f(3.3f) + 666.0f; }
though
template <typename F>
float calc1(F f) { return -1.0f * f(3.3f) + 666.0f; }
is OK. Is there a way to define an alias for calc1?
Upvotes: 1
Views: 44
Reputation: 473447
using name = thing
declares a type alias. calc1
is a template function, not a type. It's no different from declaring a variable and trying to use using
to declare an alias to it.
There is no way to declare a function alias. There are many problems with doing so, due to C++'s various rules. Do you want the alias to be for an entire overload set or just one specific function? Should the alias include ADL or not? And so forth.
Upvotes: 2