#if 0 set -xe trap 'rm -f a.out' EXIT g++ -std=c++17 fn_alias.cc && ./a.out clang++ -std=c++17 fn_alias.cc && ./a.out exit 0 #endif #include #include // Function alias. void say() { std::puts("say"); } inline constexpr auto say_alias = say; // Template function alias. // // One drawback is that template type deducation does not work through the // function pointer. One would need to write some macro wrapper. template auto add(T t, U u) -> decltype(t + u) { return t + u; } template inline constexpr auto add_int = add; // Test me. int main() { say(); say_alias(); assert(add(2, 3) == add_int(3, 2)); }