If I want to alias a template class for a known type in c++, I do something like this :
using MyVector = std::vector<MyClass>;
How do I ahieve the same for function templates?
template <typename T> void MyFunction(T MyValue);
I tried :
using MyIntFunction = MyFunction<int>;
But its not working.
Alias declarations are meant to introduce aliases for types.
Anyway, you can use a constexpr
variable to do what (I suspect) you are trying to do:
constexpr auto MyIntFunction = &MyFunction<int>;
It follows a minimal, working example:
#include<iostream>
template <typename T>
void MyFunction(T MyValue) {
std::cout << MyValue << std::endl;
}
constexpr auto MyIntFunction = &MyFunction<int>;
int main() {
MyIntFunction(42);
}
You can not use template aliases for functions, there is no such syntax.