1 | #include <utility>
|
---|
2 | #include <boost/assert.hpp>
|
---|
3 | #include <boost/range/adaptor/map.hpp>
|
---|
4 | #include <boost/range/algorithm/equal.hpp>
|
---|
5 | #include <boost/range/algorithm/copy.hpp>
|
---|
6 |
|
---|
7 | int main()
|
---|
8 | {
|
---|
9 | const std::pair<int, char> ar[] = {
|
---|
10 | std::make_pair(3, 'a'),
|
---|
11 | std::make_pair(1, 'b'),
|
---|
12 | std::make_pair(4, 'c')
|
---|
13 | };
|
---|
14 |
|
---|
15 | {
|
---|
16 | const int expected[] = {3, 1, 4};
|
---|
17 | BOOST_ASSERT(boost::equal(ar | boost::adaptors::map_keys, expected));
|
---|
18 | }
|
---|
19 |
|
---|
20 | {
|
---|
21 | const char expected[] = { 'a', 'b', 'c' };
|
---|
22 | BOOST_ASSERT(boost::equal(ar | boost::adaptors::map_values, expected));
|
---|
23 | }
|
---|
24 |
|
---|
25 | // mutable version
|
---|
26 | {
|
---|
27 | std::pair<int, char> mar[3];
|
---|
28 | boost::copy(ar, boost::begin(mar));
|
---|
29 |
|
---|
30 | const char expected[] = { 'a', 'b', 'c' };
|
---|
31 | BOOST_ASSERT(boost::equal(mar | boost::adaptors::map_values, expected));
|
---|
32 | }
|
---|
33 | }
|
---|