1 | /*============================================================================= |
---|
2 | Copyright (c) 2003 Joel de Guzman |
---|
3 | |
---|
4 | Use, modification and distribution is subject to the Boost Software |
---|
5 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
---|
6 | http://www.boost.org/LICENSE_1_0.txt) |
---|
7 | ==============================================================================*/ |
---|
8 | #include <boost/detail/lightweight_test.hpp> |
---|
9 | #include <boost/spirit/fusion/sequence/tuple.hpp> |
---|
10 | #include <boost/spirit/fusion/algorithm/find.hpp> |
---|
11 | #include <boost/spirit/fusion/iterator/deref.hpp> |
---|
12 | #include <boost/mpl/vector.hpp> |
---|
13 | |
---|
14 | struct X |
---|
15 | { |
---|
16 | operator int() const |
---|
17 | { |
---|
18 | return 12345; |
---|
19 | } |
---|
20 | }; |
---|
21 | int |
---|
22 | main() |
---|
23 | { |
---|
24 | using namespace boost::fusion; |
---|
25 | using boost::mpl::identity; |
---|
26 | using boost::mpl::vector; |
---|
27 | |
---|
28 | /// Testing find |
---|
29 | |
---|
30 | { |
---|
31 | typedef tuple<int, char, int, double> tuple_type; |
---|
32 | tuple_type t(12345, 'x', 678910, 3.36); |
---|
33 | |
---|
34 | std::cout << *boost::fusion::find(t, identity<char>()) << std::endl; |
---|
35 | BOOST_TEST(*boost::fusion::find(t, identity<char>()) == 'x'); |
---|
36 | |
---|
37 | std::cout << *boost::fusion::find(t, identity<int>()) << std::endl; |
---|
38 | BOOST_TEST(*boost::fusion::find(t, identity<int>()) == 12345); |
---|
39 | |
---|
40 | std::cout << *boost::fusion::find(t, identity<double>()) << std::endl; |
---|
41 | BOOST_TEST(*boost::fusion::find(t, identity<double>()) == 3.36); |
---|
42 | } |
---|
43 | |
---|
44 | { |
---|
45 | typedef vector<int, char, X, double> mpl_vec; |
---|
46 | BOOST_TEST((*boost::fusion::find(mpl_vec(), identity<X>()) == 12345)); |
---|
47 | } |
---|
48 | |
---|
49 | return boost::report_errors(); |
---|
50 | } |
---|
51 | |
---|