|
Boost Users : |
Subject: Re: [Boost-users] Multi index assistance
From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2010-08-16 12:51:52
Etienne Philip Pretorius <icewolfhunter <at> gmail.com> writes:
> 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 <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/cstdint.hpp>
using namespace boost::multi_index;
struct element{
element(
boost::uint8_t x,
boost::uint8_t y,
boost::uint8_t z
) : x(x),y(y),z(z) {};
boost::uint8_t x,y,z;
};
typedef multi_index_container<
element,
indexed_by<
ordered_non_unique<
member<element, boost::uint8_t, &element::x>
>,
ordered_non_unique<
member<element, boost::uint8_t, &element::y>
>,
ordered_unique<
member<element, boost::uint8_t, &element::z>
>
>
> 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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net