constexpr function parameters are not implicitly constexpr, nor can they be declared as constexpr. So, they can’t be used constant expressions within the function.
Note
If a constexpr function is used in non-constant-expression, we can pass normal arguments to them as shown below.
constexpr int min(int a, int b){ return a < b ? a : b;}int arg{1}, arg2{2};int value2{min(arg, arg2)}; // no complainconstexpr int value{min(arg, arg2)}; // fails to compile
The following will fail as we can’t use non-constexpr argument in constant expression.
constexpr void doSomething(int a){ constexpr int value{a};}