• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 1999-2003 Jaakko Jarvi
3     Copyright (c) 2001-2011 Joel de Guzman
4 
5     Distributed under the Boost Software License, Version 1.0. (See accompanying
6     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #include <boost/detail/lightweight_test.hpp>
9 #include <boost/fusion/sequence/intrinsic/at.hpp>
10 
11 #if !defined(FUSION_AT)
12 #define FUSION_AT at_c
13 #endif
14 
15 namespace test_detail
16 {
17     // no public default constructor
18     class foo
19     {
20     public:
21 
foo(int v)22         explicit foo(int v) : val(v) {}
23 
operator ==(const foo & other) const24         bool operator==(const foo& other) const
25         {
26             return val == other.val;
27         }
28 
29     private:
30 
foo()31         foo() {}
32         int val;
33     };
34 }
35 
36 void
test()37 test()
38 {
39     using namespace boost::fusion;
40     using namespace test_detail;
41 
42     FUSION_SEQUENCE<int, float, bool, foo> t1(5, 12.2f, true, foo(4));
43     FUSION_AT<0>(t1) = 6;
44     FUSION_AT<1>(t1) = 2.2f;
45     FUSION_AT<2>(t1) = false;
46     FUSION_AT<3>(t1) = foo(5);
47 
48     BOOST_TEST(FUSION_AT<0>(t1) == 6);
49     BOOST_TEST(FUSION_AT<1>(t1) > 2.1f && FUSION_AT<1>(t1) < 2.3f);
50     BOOST_TEST(FUSION_AT<2>(t1) == false);
51     BOOST_TEST(FUSION_AT<3>(t1) == foo(5));
52 }
53