Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/spirit/fusion/test/remove_tests.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 18 years ago

added boost

File size: 2.3 KB
Line 
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/sequence/io.hpp>
11#include <boost/spirit/fusion/sequence/make_tuple.hpp>
12#include <boost/spirit/fusion/sequence/equal_to.hpp>
13#include <boost/spirit/fusion/algorithm/remove.hpp>
14#include <boost/mpl/vector.hpp>
15#include <boost/mpl/identity.hpp>
16
17struct X
18{
19    operator char const*() const
20    {
21        return "<X-object>";
22    }
23};
24
25struct Y
26{
27    operator char const*() const
28    {
29        return "<Y-object>";
30    }
31};
32
33int
34main()
35{
36    using namespace boost::fusion;
37    using boost::mpl::identity;
38    using boost::mpl::vector;
39    namespace fusion = boost::fusion;
40
41    std::cout << tuple_open('[');
42    std::cout << tuple_close(']');
43    std::cout << tuple_delimiter(", ");
44
45/// Testing remove
46
47    X x; Y y;
48    typedef tuple<Y, char, long, X, bool, double> tuple_type;
49    tuple_type t(y, '@', 987654, x, true, 6.6);
50
51    {
52        std::cout << fusion::remove(t, identity<X>()) << std::endl;
53        BOOST_TEST((fusion::remove(t, identity<X>())
54            == make_tuple(y, '@', 987654, true, 6.6)));
55    }
56
57    {
58        std::cout << fusion::remove(t, identity<Y>()) << std::endl;
59        BOOST_TEST((fusion::remove(t, identity<Y>())
60            == make_tuple('@', 987654, x, true, 6.6)));
61    }
62
63    {
64        std::cout << fusion::remove(t, identity<long>()) << std::endl;
65        BOOST_TEST((fusion::remove(t, identity<long>())
66            == make_tuple(y, '@', x, true, 6.6)));
67    }
68
69    {
70        typedef vector<Y, char, long, X, bool, double> mpl_vec;
71        BOOST_TEST((fusion::remove(mpl_vec(), identity<X>())
72            == tuple<Y, char, long, bool, double>()));
73        BOOST_TEST((fusion::remove(mpl_vec(), identity<Y>())
74            == tuple<char, long, X, bool, double>()));
75        BOOST_TEST((fusion::remove(mpl_vec(), identity<long>())
76            == tuple<Y, char, X, bool, double>()));
77    }
78
79    return boost::report_errors();
80}
81
Note: See TracBrowser for help on using the repository browser.