Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/xpressive/detail/utility/any.hpp @ 33

Last change on this file since 33 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 3.0 KB
Line 
1///////////////////////////////////////////////////////////////////////////////
2// any.hpp
3//
4//  Copyright 2004 Eric Niebler. Distributed under the Boost
5//  Software License, Version 1.0. (See accompanying file
6//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
8#ifndef BOOST_XPRESSIVE_DETAIL_UTILITY_ANY_HPP_EAN_11_19_2005
9#define BOOST_XPRESSIVE_DETAIL_UTILITY_ANY_HPP_EAN_11_19_2005
10
11#include <boost/version.hpp>
12
13#if BOOST_VERSION >= 103300
14
15// In Boost 1.33+, we have a cons list in Fusion, so just include it.
16# include <boost/spirit/fusion/algorithm/any.hpp>
17
18#else
19
20# include <boost/spirit/fusion/sequence/begin.hpp>
21# include <boost/spirit/fusion/sequence/end.hpp>
22# include <boost/spirit/fusion/iterator/equal_to.hpp>
23# include <boost/mpl/bool.hpp>
24# include <boost/spirit/fusion/iterator/equal_to.hpp>
25# include <boost/spirit/fusion/iterator/next.hpp>
26# include <boost/spirit/fusion/iterator/deref.hpp>
27
28namespace boost { namespace fusion
29{
30
31    namespace detail
32    {
33        template <typename First, typename Last, typename F>
34        inline bool
35        any(First const&, Last const&, F const&, mpl::true_)
36        {
37            return false;
38        }
39
40        template <typename First, typename Last, typename F>
41        inline bool
42        any(First const& first, Last const& last, F const& f, mpl::false_)
43        {
44            if(f(*first))
45                return true;
46            return detail::any(fusion::next(first), last, f
47              , meta::equal_to<BOOST_DEDUCED_TYPENAME meta::next<First>::type, Last>());
48        }
49    }
50
51    namespace meta
52    {
53        template <typename Sequence, typename F>
54        struct any
55        {
56            typedef bool type;
57        };
58    }
59
60    namespace function
61    {
62        struct any
63        {
64            template <typename Sequence, typename F>
65            struct apply
66            {
67                typedef bool type;
68            };
69
70            template <typename Sequence, typename F>
71            inline bool
72            operator()(Sequence const& seq, F const& f) const
73            {
74                return detail::any(
75                        fusion::begin(seq)
76                      , fusion::end(seq)
77                      , f
78                      , meta::equal_to<
79                            BOOST_DEDUCED_TYPENAME meta::begin<Sequence>::type
80                          , BOOST_DEDUCED_TYPENAME meta::end<Sequence>::type>());
81            }
82
83            template <typename Sequence, typename F>
84            inline bool
85            operator()(Sequence& seq, F const& f) const
86            {
87                return detail::any(
88                        fusion::begin(seq)
89                      , fusion::end(seq)
90                      , f
91                      , meta::equal_to<
92                            BOOST_DEDUCED_TYPENAME meta::begin<Sequence>::type
93                          , BOOST_DEDUCED_TYPENAME meta::end<Sequence>::type>());
94            }
95        };
96    }
97
98    function::any const any = function::any();
99}}
100
101#endif
102
103#endif
Note: See TracBrowser for help on using the repository browser.