0

I'm trying to initialise a member of type ::std::array<T,N>. However it doesn't take an initializer_list which I pass through the argument list. This boils down to:

#include <initializer_list>
#include <array>

int main() {
  ::std::initializer_list<int> il = {4,2};
  ::std::array<int,2> a = il; 
}

The array refuses to initialise from it. What is the intended way to cram data from an initializer_list into an std::array?

Note: I am compiling with C++17.

bitmask
  • 32,434
  • 14
  • 99
  • 159

0 Answers0