Boost logo

Boost Users :

Subject: [Boost-users] how to lisk unique keys in boost multi_index_container
From: Bill Tian (billtian945_at_[hidden])
Date: 2014-12-02 11:01:15

hello,every one

now i have a struct like this

struct a {
a(const std::string &m1_, const std::string &m2_, boost::int16_t m3_)
: m1(m1_),m2(m2_), m3(m3_) {}
std::string m1;
std::string m2;
boost::int16_t m3;

typedef boost::multi_index::multi_index_container <
        BOOST_MULTI_INDEX_MEMBER(a, std::string, m1)
        BOOST_MULTI_INDEX_MEMBER(a, std::string, m2)
      boost::multi_index::ordered_non_unique <
        BOOST_MULTI_INDEX_MEMBER(a, boost::uint16_t, m3)
> my_data;
i want to list all unique keys of m2 and m3 after the container has been
filled with a lot of records, is there a example ?

my_data data;
data.insert(a("a1","k1", 1));
data.insert(a("a2","k1", 2));
data.insert(a("a3","k2", 3));
data.insert(a("a10000","k1", 1));

i want to get all data that m2 equal to "k1", when this data has been
processed, get all data that m2 equal to "k2" ... but i do not how many
unique keys in the container, am i need to store another set to store that
when i fill the container?
i need a function to get the keys like the SQL:"select distinct(m2) from

thanks a lot!

best regards.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at