| 1 | #include <boost/detail/lightweight_test.hpp>
|
|---|
| 2 | #include <boost/config.hpp>
|
|---|
| 3 | #include <vector>
|
|---|
| 4 |
|
|---|
| 5 | #include <boost/multi_index_container.hpp>
|
|---|
| 6 | #include <boost/multi_index/ordered_index.hpp>
|
|---|
| 7 | #include <boost/multi_index/hashed_index.hpp>
|
|---|
| 8 | #include <boost/multi_index/random_access_index.hpp>
|
|---|
| 9 | #include <boost/multi_index/sequenced_index.hpp>
|
|---|
| 10 | #include <boost/range/algorithm/equal.hpp>
|
|---|
| 11 |
|
|---|
| 12 | struct ord_tag {};
|
|---|
| 13 | struct hash_tag {};
|
|---|
| 14 | struct rand_tag {};
|
|---|
| 15 | struct seq_tag {};
|
|---|
| 16 |
|
|---|
| 17 | using namespace boost::multi_index;
|
|---|
| 18 | typedef multi_index_container<
|
|---|
| 19 | int,
|
|---|
| 20 | indexed_by<
|
|---|
| 21 | ordered_unique<tag<ord_tag>, identity<int> >,
|
|---|
| 22 | hashed_unique<tag<hash_tag>, identity<int> >,
|
|---|
| 23 | random_access<tag<rand_tag> >,
|
|---|
| 24 | sequenced<tag<seq_tag> >
|
|---|
| 25 | >
|
|---|
| 26 | > container;
|
|---|
| 27 |
|
|---|
| 28 | #if defined(BOOST_NO_INITIALIZER_LISTS)
|
|---|
| 29 | int main() {}
|
|---|
| 30 | #else
|
|---|
| 31 | int main()
|
|---|
| 32 | {
|
|---|
| 33 | const container c = {3, 1, 4};
|
|---|
| 34 | {
|
|---|
| 35 | const std::vector<int> expected = {1, 3, 4};
|
|---|
| 36 | BOOST_TEST(boost::equal(c, expected));
|
|---|
| 37 | BOOST_TEST(boost::equal(c.get<ord_tag>(), expected));
|
|---|
| 38 | BOOST_TEST(boost::equal(c.get<hash_tag>(), expected));
|
|---|
| 39 | }
|
|---|
| 40 | {
|
|---|
| 41 | const std::vector<int> expected = {3, 1, 4};
|
|---|
| 42 | BOOST_TEST(boost::equal(c.get<rand_tag>(), expected));
|
|---|
| 43 | BOOST_TEST(boost::equal(c.get<seq_tag>(), expected));
|
|---|
| 44 | }
|
|---|
| 45 | return boost::report_errors();
|
|---|
| 46 | }
|
|---|
| 47 | #endif
|
|---|
| 48 |
|
|---|