• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 1999-2003 Jaakko Jarvi
3     Copyright (c) 2001-2011 Joel de Guzman
4     Copyright (c) 2006
5 
6     Distributed under the Boost Software License, Version 1.0. (See accompanying
7     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 ==============================================================================*/
9 #include <boost/fusion/container/map/map.hpp>
10 #include <boost/detail/lightweight_test.hpp>
11 #include <boost/fusion/sequence/intrinsic/at.hpp>
12 
13 struct k1 {};
14 struct k2 {};
15 struct k3 {};
16 struct k4 {};
17 
18 namespace test_detail
19 {
20     // no public default constructor
21     class foo
22     {
23     public:
24 
foo(int v)25         explicit foo(int v) : val(v) {}
26 
operator ==(const foo & other) const27         bool operator==(const foo& other) const
28         {
29             return val == other.val;
30         }
31 
32     private:
33 
foo()34         foo() {}
35         int val;
36     };
37 }
38 
39 void
test()40 test()
41 {
42     using namespace boost::fusion;
43     using namespace test_detail;
44 
45     map<
46         pair<k1, int>,
47         pair<k1, float>,
48         pair<k1, bool>,
49         pair<k1, foo>
50     > t1(5, 12.2f, true, foo(4));
51 
52     at_c<0>(t1).second = 6;
53     at_c<1>(t1).second = 2.2f;
54     at_c<2>(t1).second = false;
55     at_c<3>(t1).second = foo(5);
56 
57     BOOST_TEST(at_c<0>(t1).second == 6);
58     BOOST_TEST(at_c<1>(t1).second > 2.1f && at_c<1>(t1).second < 2.3f);
59     BOOST_TEST(at_c<2>(t1).second == false);
60     BOOST_TEST(at_c<3>(t1).second == foo(5));
61 }
62 
63 int
main()64 main()
65 {
66     test();
67     return boost::report_errors();
68 }
69 
70