The perfect function alias
Is there a situation where the compiler will not optimize away the wrapper because the wrapper and the original function have different semantics?


Yes to the first part and no to the second. Any optimizing compiler will inline your wrapper, as it consists of only one return statement.

But on the other hand, the original function might have different semantics: It might be constexpr for example, and your alias will not be.


  Does this fail to compile for some functions?


No (except for the constexpr part).

So here are some improvements you can use:


Templates are implicitly inline, so you don't need to write it explicitly.
Use a lambda to combat the missing constexprness of the alias, because since C++17 lambdas are implicitly constexpr if they can be.


This will get you:

#define FUN_ALIAS(NEW_NAME, ...)                                                \
  inline auto NEW_NAME = [](auto &amp;&amp;... args)                                   \
    noexcept(noexcept(__VA_ARGS__(std::forward&lt;decltype(args)&gt;(args)...)))     \
    -&gt; decltype(auto) {                                                        \
    return __VA_ARGS__(std::forward&lt;decltype(args)&gt;(args)...);                \
  };