1

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.