mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-23 00:57:20 +02:00
Made map random access. Thanks to Brandon Kohn!
[SVN r74882]
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
==============================================================================*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/container/map/map.hpp>
|
||||
#include <boost/fusion/adapted/mpl.hpp>
|
||||
#include <boost/fusion/sequence/io/out.hpp>
|
||||
#include <boost/fusion/container/generation/make_vector.hpp>
|
||||
@ -82,6 +83,27 @@ main()
|
||||
));
|
||||
}
|
||||
|
||||
//! Map
|
||||
{
|
||||
typedef pair<boost::mpl::int_<0>, std::string> pair0;
|
||||
typedef pair<boost::mpl::int_<1>, std::string> pair1;
|
||||
typedef pair<boost::mpl::int_<2>, std::string> pair2;
|
||||
typedef pair<boost::mpl::int_<3>, std::string> pair3;
|
||||
typedef pair<boost::mpl::int_<4>, std::string> pair4;
|
||||
|
||||
typedef map< pair0, pair1, pair2, pair3, pair4 > map_type;
|
||||
map_type m( pair0("zero"), pair1("one"), pair2("two"), pair3("three"), pair4("four") );
|
||||
typedef reverse_view<map_type> view_type;
|
||||
view_type rev(m);
|
||||
std::cout << rev << std::endl;
|
||||
BOOST_TEST((rev == make_vector( pair4("four"), pair3("three"), pair2("two"), pair1("one"), pair0("zero"))));
|
||||
BOOST_TEST((at_c<0>(rev) == pair4("four")));
|
||||
BOOST_TEST((at_c<1>(rev) == pair3("three")));
|
||||
BOOST_TEST((at_c<2>(rev) == pair2("two")));
|
||||
BOOST_TEST((at_c<3>(rev) == pair1("one")));
|
||||
BOOST_TEST((at_c<4>(rev) == pair0("zero")));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user