std::array with custom type not behaving as expected in constexpr context
I'm trying to use `std::array` with a custom type in a `constexpr` context, but I'm running into issues when attempting to initialize it with a constructor that takes parameters. Specifically, I get the behavior message: `behavior: 'myArray' is not a constant expression`. Hereβs a simplified version of my code: ```cpp #include <array> #include <iostream> #include <stdexcept> class MyType { public: constexpr MyType(int x) : value(x) {} constexpr int getValue() const { return value; } private: int value; }; constexpr std::array<MyType, 3> myArray = {{ MyType(1), MyType(2), MyType(3) }}; int main() { for (const auto& item : myArray) { std::cout << item.getValue() << '\n'; } return 0; } ``` Iβve confirmed that `MyType` has a `constexpr` constructor and method, but when I try to compile this code with GCC 11.2, I receive the aforementioned behavior. I also tried using `std::array` with built-in types like `int` and it works perfectly, but introducing my custom type seems to break the `constexpr` evaluation. I've read that `std::array` should work with `constexpr` if the elements are `constexpr` constructible. Is there something Iβm missing in how I'm initializing or using the `std::array`? Any insights on how to resolve this would be greatly appreciated. My goal is to keep everything at compile time for performance reasons, especially since Iβm working on a performance-sensitive application.