4 ms·
It is kind of weird at first but the reason is that `std::vector` requires heap allocation and transient allocations are not allowed in `constexpr` contexts. Th
by SuperV1234 5mo ago
It is kind of weird at first but the reason is that `std::vector` requires heap allocation and transient allocations are not allowed in `constexpr` contexts. The purpose of `std::define_static_array` is to promote the storage of the vector to static storage to eliminate the transient allocation issue, and so that the `template for` can work properly with it.
See wg21.link/P3491
- mort96 5mo agoIs there a reason why `std::meta::enumerators_of`, a reflection feature that's surely almost exclusively going to be used in constexpr contexts, returns a value which doesn't work in constexpr contexts?
- SuperV1234 5mo agoIt works generally, but not with expansion statements. See section 3.2 here: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p1306r4.html https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p13... It seems that this is being worked on, and eventually the `define_static_array` won't be needed anymore
- mort96 5mo agoJust another example where C++ language features are incompatible with each other, to be fixed "in a later version" which may or may not happen. There are so many of those in C++. I desperately wish they'd just do it properly initially.
- pjmlp 5mo agoMe too, unfortunately the old guard sees no value in implementation before standardisation for each single feature. So it is as it is, plenty of software in C++ isn't going to be rewriten into something else. Maybe someone can do a Claude rewrite from LLVM into something else. /s