dimanche 27 août 2017

C++11 inserting element into a list of arrays

I am trying to use an STL container to hold arrays, but I do not know how can I insert elements into it. I was trying different approaches and non of it worked for me. Also google is helpless in this case. Here is what I am trying to do:

std::forward_list<int[5]> buffers;
buffers.push_front(); // What should I pass to create uninitialized array

Even this approach does not works

typedef int Buffer[5];
std::forward_list<Buffer> buffers;
Buffer buff;
buffers.push_front(buff);

The only way which works is to wrap array with a class. Then everything is ok, however I wanted to know how should I do this correctly in C++

Aucun commentaire:

Enregistrer un commentaire