Hello List, I have defined a multi_index container, but I am not able to populate the container. Is there something that I have missed? struct element { element( std::uint8_t x, std::uint8_t y, std::uint8_t z ) : x(x),y(y),z(z) {}; std::uint8_t x,y,z; }; typedef boost::multi_index_container< element, boost::multi_index::indexed_by< boost::multi_index::ordered_non_unique< boost::multi_index::member< element, std::uint8_t, &element::x
,
boost::multi_index::ordered_non_unique< boost::multi_index::member< element, std::uint8_t, &element::y
,
boost::multi_index::ordered_unique< boost::multi_index::member< element, std::uint8_t, &element::z
matrix_t;
Then I define: matrix_t m; element e(1,2,3); m.insert <-- not valid So what is the correct way to populate the container? Kind Regards, Etienne
Etienne Philip Pretorius
Hello List,
I have defined a multi_index container, but I am not able to populate the container. Is there something that I have missed?
struct element { [...] };
typedef boost::multi_index_container< element, [...] > matrix_t;
Then I define:
matrix_t m; element e(1,2,3); m.insert <-- not valid
The correct syntax is
m.insert(e);
The following complete program compiles succesfully,
code is identical to yours except that I used boost::uint8_t
instead of std::uint8_t, which does not exist in my platform:
#include
matrix_t;
int main() { matrix_t m; element e(1,2,3); m.insert(e); } HTH, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (2)
-
Etienne Philip Pretorius
-
Joaquin M Lopez Munoz