The constexpr
function pointer can be used as a function alias.
namespace bar
{
int f();
}
constexpr auto g = bar::f;
It is highly likely (but not guaranteed by the language) that using g
uses bar::f
directly.
Specifically, this depends on compiler version and optimization level.
In particular, this is the case for:
- GCC 4.7.1+, without optimization,
- Clang 3.1+, without optimization,
- MSVC 19.14+, with optimization.
See assembly generated by these compilers.