c++ - How do I store arrays in an STL list? -
Does anyone know how to store integer arrays in the form of nodes in an STL list or vector, to use C ++ and STL? I have an unknown number of numbers that I need to store, and come from other languages, my first idea was to use a sort of catalog- or vector-like data structure ... but I'm having some trouble I am 100% confident that I am making an initial C ++ mistake, and who actually knows the language, he will see once what I am trying to do and to set me straight I'm capable. > So, what I have tried here is to declare such a task list:
stl :: list & lt; Int [2] & gt; My list; And then I can easily create a two-element array, such as:
int foo [2] = {1,2}; It compiles and runs just fine. However, as soon as I try to add foo to my list, such as:
my_list.push_back (foo); I get a complete set of compiler errors, none of which I really understand (my C ++ - FU is almost not present):
/ usr / includes / c ++ / 4.0.0 / ext / new_allocator.h: Members 'function in' __gnu_cxx :: new_allocator & lt; _Tp & gt; :: Construction (_Tp *, Constants _Tp & amp;) [with _Tp = int [2]] ': /usr/include/c++/4.0.0/bits/stl_list.h:440:' instantiated from std :: _ List_node & LT; _Tp & gt; * Std :: from the list & lt; _Tp, _Alloc & gt; :: _ M_create_node (constant_ _Tp & amp;) [with _Tp = int [2], _Alloc = std :: communicator & lt; Integer [2] & gt;] /usr/include/c++/4.0.0/bits/stl_list.h:1151: instantiated from 'zero std :: list & lt; _Tp, _Alloc & gt; :: _ M_insert (std :: _ List_iterator & lt; _Tp>, constants _Tp & amp;) [with _Tp = int [2], _Alloc = std :: effector & lt; Integer [2] & gt;] '/ usr / includes / c ++ / 4.0.0 / bits / stl_list.h: 773:' instantiated from zero std :: list & lt; _Tp, _Alloc & gt; :: push_back (constant _Tp & amp;) [_Tp = int [2], _Alloc = std :: communicator & lt; Integer [2] & gt;] 'test.cpp: 5: Started from here / usr / include /c++/4.0.0/ext/new_allocator.h.104: Error: ISO C ++ Start Array Denied in New So, what are the ideas I'm doing wrong here in someone? Any hint (some pun intended) would be most useful, is it not possible to store an array in std :: list? Should I Use A Straight? Do I have a * or & amp; missing?