How do I store arrays in an STL list?

The thing stored in a Standard Library container must be assignable and copyable – arrays are neither. Your best bet is to create a list of std::vector. Alternatively, you can wrap the array in a struct:

struct A {
   int array[2];
};

std::list <A> alist;

Leave a Comment