Publishing R3
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / common / boost / 1.64.0 / include / boost-1_64 / boost / fusion / algorithm / query / detail / all.hpp
1 /*=============================================================================
2     Copyright (c) 2001-2011 Joel de Guzman
3     Copyright (c) 2007 Dan Marsden
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 #if !defined(FUSION_ALL_05052005_1237)
9 #define FUSION_ALL_05052005_1237
10
11 #include <boost/fusion/support/config.hpp>
12 #include <boost/mpl/bool.hpp>
13 #include <boost/fusion/sequence/intrinsic/begin.hpp>
14 #include <boost/fusion/sequence/intrinsic/end.hpp>
15 #include <boost/fusion/iterator/advance.hpp>
16 #include <boost/fusion/iterator/equal_to.hpp>
17 #include <boost/fusion/iterator/next.hpp>
18 #include <boost/fusion/iterator/deref.hpp>
19 #include <boost/fusion/iterator/distance.hpp>
20
21 namespace boost { namespace fusion { namespace detail
22 {
23     template <typename First, typename Last, typename F>
24     BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
25     inline bool
26     linear_all(First const&, Last const&, F const&, mpl::true_)
27     {
28         return true;
29     }
30
31     template <typename First, typename Last, typename F>
32     BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
33     inline bool
34     linear_all(First const& first, Last const& last, F& f, mpl::false_)
35     {
36         typename result_of::deref<First>::type x = *first;
37         return f(x) &&
38             detail::linear_all(
39                 fusion::next(first)
40               , last
41               , f
42               , result_of::equal_to<typename result_of::next<First>::type, Last>());
43     }
44
45     template <typename Sequence, typename F, typename Tag>
46     BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
47     inline bool
48     all(Sequence const& seq, F f, Tag)
49     {
50         return detail::linear_all(
51                 fusion::begin(seq)
52               , fusion::end(seq)
53               , f
54               , result_of::equal_to<
55                     typename result_of::begin<Sequence>::type
56                   , typename result_of::end<Sequence>::type>());
57     }
58
59     template<int N>
60     struct unrolled_all
61     {
62         template <typename It, typename F>
63         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
64         static bool call(It const& it, F f)
65         {
66             return
67                 f(*it) &&
68                 f(*fusion::advance_c<1>(it))&&
69                 f(*fusion::advance_c<2>(it)) &&
70                 f(*fusion::advance_c<3>(it)) &&
71                 detail::unrolled_all<N-4>::call(fusion::advance_c<4>(it), f);
72         }
73     };
74
75     template<>
76     struct unrolled_all<3>
77     {
78         template <typename It, typename F>
79         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
80         static bool call(It const& it, F f)
81         {
82             return
83                 f(*it) &&
84                 f(*fusion::advance_c<1>(it)) &&
85                 f(*fusion::advance_c<2>(it));
86         }
87     };
88
89     template<>
90     struct unrolled_all<2>
91     {
92         template <typename It, typename F>
93         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
94         static bool call(It const& it, F f)
95         {
96             return
97                 f(*it) &&
98                 f(*fusion::advance_c<1>(it));
99         }
100     };
101
102     template<>
103     struct unrolled_all<1>
104     {
105         template <typename It, typename F>
106         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
107         static bool call(It const& it, F f)
108         {
109             return f(*it);
110         }
111     };
112
113     template<>
114     struct unrolled_all<0>
115     {
116         template <typename It, typename F>
117         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
118         static bool call(It const& /*it*/, F /*f*/)
119         {
120             return true;
121         }
122     };
123
124     template <typename Sequence, typename F>
125     BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
126     inline bool
127     all(Sequence const& seq, F f, random_access_traversal_tag)
128     {
129         typedef typename result_of::begin<Sequence>::type begin;
130         typedef typename result_of::end<Sequence>::type end;
131         return detail::unrolled_all<result_of::distance<begin, end>::type::value>::call(
132             fusion::begin(seq), f);
133     }
134 }}}
135
136 #endif
137