:
constexpr int doit(int input, bool inconst = false) {
return inconst ? doitconsty(input) : doitfast(input);
}
doit constexpr, - ,
constexpr int f(int n, bool inconst = false) {
int importantInt = doit(n / 42, inconst);
return magicResult;
}
constexpr , , . inconst
enum foo { bar = f(256, true) }
, f,
int main() { std::cout << "test-case: " << f(256); }
, , boolean . -, ( , int bool, ).
template<typename T>
struct maybe_const_value {
T t;
bool isconst;
};
enum foo { bar = maybe_const_value{256, true} % magicTransform };
int main() { return maybe_const_value{265} % magicTransform; }
input.isconst input.t .