🔮🚀 Wow, #C++26 can’t do magic tricks! Arthur O'Dwyer spins a riveting yarn about... defining static arrays? Apparently, your favorite language still can’t conjure heap allocations out of thin air, leaving C++ wizards everywhere 🧙 scratching their heads. Who knew the compiler's "imagination" had limits?! 😱
https://quuxplusone.github.io/blog/2026/04/24/define-static-array/ #StaticArrays #CompilerLimits #ProgrammingMagic #C++Wizards #HackerNews #ngated
https://quuxplusone.github.io/blog/2026/04/24/define-static-array/ #StaticArrays #CompilerLimits #ProgrammingMagic #C++Wizards #HackerNews #ngated
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.