Open Nufunello opened 2 years ago
For example:
{
auto res = 1;
if constexpr (do_multiply)
{
res *= 2;
}
return res;
}
In this case, would be good thing constexpr ternary
or invoking lambda with if constexpr inside. Since, in c++ is no constexpr ternary
and instantly invoking lambda with all possible conditions is not friendly API - there is place for new approach
Motivation: provide API for selecting expressions at compile time at same code scope
if we want to execute different code depending on compile time expression we will use
if constexpr
, but when if there is need to useconst
if constexpr
won't work