]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/include/boost/spirit/home/support/algorithm/any.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / support / algorithm / any.hpp
1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #if !defined(BOOST_SPIRIT_ANY_APRIL_22_2006_1147AM)
8 #define BOOST_SPIRIT_ANY_APRIL_22_2006_1147AM
9
10 #if defined(_MSC_VER)
11 #pragma once
12 #endif
13
14 #include <boost/mpl/bool.hpp>
15 #include <boost/fusion/include/equal_to.hpp>
16 #include <boost/fusion/include/next.hpp>
17 #include <boost/fusion/include/deref.hpp>
18 #include <boost/fusion/include/begin.hpp>
19 #include <boost/fusion/include/end.hpp>
20 #include <boost/fusion/include/any.hpp>
21 #include <boost/spirit/home/support/unused.hpp>
22
23 namespace boost { namespace spirit
24 {
25 // This is the binary version of fusion::any. This might
26 // be a good candidate for inclusion in fusion algorithm
27
28 namespace detail
29 {
30 template <typename First1, typename Last, typename First2, typename F>
31 inline bool
32 any(First1 const&, First2 const&, Last const&, F const&, mpl::true_)
33 {
34 return false;
35 }
36
37 template <typename First1, typename Last, typename First2, typename F>
38 inline bool
39 any(First1 const& first1, First2 const& first2, Last const& last, F& f, mpl::false_)
40 {
41 return f(*first1, *first2) ||
42 detail::any(
43 fusion::next(first1)
44 , fusion::next(first2)
45 , last
46 , f
47 , fusion::result_of::equal_to<
48 typename fusion::result_of::next<First1>::type, Last>());
49 }
50 }
51
52 template <typename Sequence1, typename Sequence2, typename F>
53 inline bool
54 any(Sequence1 const& seq1, Sequence2& seq2, F f)
55 {
56 return detail::any(
57 fusion::begin(seq1)
58 , fusion::begin(seq2)
59 , fusion::end(seq1)
60 , f
61 , fusion::result_of::equal_to<
62 typename fusion::result_of::begin<Sequence1>::type
63 , typename fusion::result_of::end<Sequence1>::type>());
64 }
65
66 template <typename Sequence, typename F>
67 inline bool
68 any(Sequence const& seq, unused_type, F f)
69 {
70 return fusion::any(seq, f);
71 }
72
73 }}
74
75 #endif
76