3 ms·
That's what everybody originally believes (me included)! constexpr is_right_answer(int x){ if (x==42) return true; else { std::cout <<"t
by gpderetta 4y ago
That's what everybody originally believes (me included)!
constexpr is_right_answer(int x){
if (x==42) return true;
else {
std::cout <<"try again \n";
return false;
}
A function can be constexpr as long as at least one possible invocation can be compile time evaluated. In fact compilers can't generally prove that a function can't be constexpr.
I believe consteval has the semantics you want but I've yet to study it in details.
For more details see: https://www.foonathan.net/2020/10/constexpr-platform/ https://www.foonathan.net/2020/10/constexpr-platform/ .
- cbsmith 4y agoI stand corrected.