I want initialize base class with std::initializer_list
.
struct A : public std::array<int, 4>
{
// This constructor works fine
A()
: std::array<int, 4>{{ 1, 2, 3, 4 }}
{
}
// THIS CONSTRUCTOR FAILS TO COMPILE
A(std::initializer_list<int> il)
: std::array<int, 4>{il}
{
}
};
GCC error for second constructor is
error: array must be initialized with a brace-enclosed initializer
What I want is to initialize new A instance with initializer_list like this
A var{{ 1, 2, 3, 4 }}
and pass it to base class.