От: | Pavel Dvorkin | ||
Дата: | 23.11.24 13:24 | ||
Оценка: | +1 |
The following solution:
class C {
public:
static constexpr const void* noop = reinterpret_cast<const void*>(0x1);
};
Although, it compiles and works fine in GCC isn't valid C++ (e.g., it doesn't compile with either clang or VC++2013) because according to the standard § 5.19/2 Constant Expressions [expr.const] the result of a reinterpret_cast can't be a constant expression.