Tag: member-initialization
-
Is gcc wrong to allow the initialization of a const array member with another array reference?
8 While (re)implementing a simple constexpr map, I wrote this (godbolt): template <class key_type, class value_type, int N> class flat_map { private: struct pair { key_type key; value_type value; }; const pair elements[N]; public: consteval flat_map(const pair (&arr)[N]) noexcept : elements(arr) // works on gcc?! {} [[nodiscard]] consteval value_type operator[](const key_type key) const { for…