3 ms·
constexpr is often difficult to get right. For example, we use a wide_integer type for 128 and 256-bit integers: https://github.com/ClickHouse/ClickHouse/blob/
by zX41ZdbW 3y ago
constexpr is often difficult to get right.
For example, we use a wide_integer type for 128 and 256-bit integers: https://github.com/ClickHouse/ClickHouse/blob/master/base/base/wide_integer_impl.h https://github.com/ClickHouse/ClickHouse/blob/master/base/ba...
It was developed by a C++ expert to fit into the C++ standard, so it has constexpr everywhere. But for this reason, we cannot use memcpy inside its methods and have to wait for a new standard with constexpr memcpy. Note: memcpy is to satisfy strict aliasing - we can use std::bit_cast instead, but there was some trouble.
- gpderetta 3y agoI'm still on C++20, so I haven't had a chance to try it yet, bit 'if consteval' should allow fixing this, right?
- zX41ZdbW 3y agoThank you! Should work. PS. When reading about `consteval`, `constinit` you might think, "they (C++ committee) are totally crazy, how they think we can follow"