Things C++26 define_static_array can't do
We’ve seen previously
that it’s not possible to create a constexpr global variable of container type,
when that container holds a pointer to a heap allocation. It’s fine to create a
global constexpr std::array, or even a std::string that uses only its SSO buffer;
but you can’t create a global constexpr std::vector or std::list (unless it’s
empty) because it would have to hold a pointer to a heap allocation.
that it’s not possible to create a constexpr global variable of container type,
when that container holds a pointer to a heap allocation. It’s fine to create a
global constexpr std::array, or even a std::string that uses only its SSO buffer;
but you can’t create a global constexpr std::vector or std::list (unless it’s
empty) because it would have to hold a pointer to a heap allocation.
Summary not yet generated for this article.
Comments (18 of ) ⌛