Код: Выделить всё
#include
constexpr bool x = [] {
return std::bit_cast('\2');
}();
int main() {
return x;
}
Код: Выделить всё
:3:16: error: constexpr variable 'x' must be initialized by a constant expression
/opt/compiler-explorer/clang-20.1.0/bin/../include/c++/v1/__bit/bit_cast.h:37:10: note: value 2 cannot be represented in type 'bool'
Какая реализация здесь правильная?
Подробнее здесь: https://stackoverflow.com/questions/796 ... tdbit-cast
Мобильная версия