Here is a container of ints with a sequence index and a hashed index:
#include <iostream>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/identity.hpp>
#include <boost/multi_index/sequenced_index.hpp>
int main()
{
namespace bmi = boost::multi_index;
boost::multi_index_container<
int,
bmi::indexed_by<
bmi::sequenced<>,
bmi::hashed_unique<bmi::identity<int>>
>
> c;
for (int i=0; i<100; ++i) c.push_back(i);
for (int j : c) std::cout << " " << j;
std::cout << std::endl;
return 0;
}
Note I did not use get
in the second loop. Is the behavior defined in this case? (E.g., "This is the same as using .get<0>()
".)
Yes, index #0 is the default in the sense explained here:
The functionality of index #0 can be accessed directly from a multi_index_container object without using get<0>()
: for instance, es.begin()
is equivalent to es.get<0>().begin()
.