Why is double brace required to initialize std::array of structs

In C++17, why does this way of initializing std::array not work?

class myClass {

private  

 struct myStruct {
        const std::string_view a;
        const int b;
        const int c;
    };

    static inline constexpr std::array<myStruct, 2> myArray = {{"", 0, 0},{"", 0, 0}};

I thought this style was covered by the changes in CWG 1270. However, the only way I found to make it work is to do:

   static inline constexpr std::array<myStruct, 2> myArray = {{{"", 0, 0},{"", 0, 0}}};

or

   static inline constexpr std::array<myStruct, 2> myArray = {myStruct{"", 0, 0},myStruct{"", 0, 0}};


Read more here: https://stackoverflow.com/questions/67169996/why-is-double-brace-required-to-initialize-stdarray-of-structs

Content Attribution

This content was originally published by Fábio Mestre at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: