]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/type_erasure/detail/extract_concept.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / type_erasure / detail / extract_concept.hpp
1 // Boost.TypeErasure library
2 //
3 // Copyright 2011 Steven Watanabe
4 //
5 // Distributed under the Boost Software License Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // $Id$
10
11 #if !defined(BOOST_PP_IS_ITERATING)
12
13 #ifndef BOOST_TYPE_ERASURE_DETAIL_EXTRACT_CONCEPT_HPP_INCLUDED
14 #define BOOST_TYPE_ERASURE_DETAIL_EXTRACT_CONCEPT_HPP_INCLUDED
15
16 #include <boost/mpl/eval_if.hpp>
17 #include <boost/mpl/identity.hpp>
18 #include <boost/type_traits/remove_cv.hpp>
19 #include <boost/type_traits/remove_reference.hpp>
20 #include <boost/preprocessor/cat.hpp>
21 #include <boost/preprocessor/inc.hpp>
22 #include <boost/preprocessor/iteration/iterate.hpp>
23 #include <boost/preprocessor/repetition/repeat.hpp>
24 #include <boost/preprocessor/repetition/enum_params.hpp>
25 #include <boost/type_erasure/is_placeholder.hpp>
26 #include <boost/type_erasure/concept_of.hpp>
27 #include <boost/type_erasure/config.hpp>
28
29 namespace boost {
30 namespace type_erasure {
31 namespace detail {
32
33 template<class T, class U>
34 struct combine_concepts;
35
36 template<class T>
37 struct combine_concepts<T, T> { typedef T type; };
38 template<class T>
39 struct combine_concepts<T, void> { typedef T type; };
40 template<class T>
41 struct combine_concepts<void, T> { typedef T type; };
42 template<>
43 struct combine_concepts<void, void> { typedef void type; };
44
45 #ifdef BOOST_TYPE_ERASURE_USE_MP11
46
47 template<class T, class U>
48 using combine_concepts_t = typename ::boost::type_erasure::detail::combine_concepts<T, U>::type;
49
50 template<class T, class U>
51 using extract_concept_or_void =
52 ::boost::mp11::mp_eval_if_c<
53 !::boost::type_erasure::is_placeholder<
54 ::boost::remove_cv_t<
55 ::boost::remove_reference_t<T>
56 >
57 >::value,
58 void,
59 ::boost::type_erasure::concept_of_t, U
60 >;
61
62 template<class L1, class L2>
63 using extract_concept_t =
64 ::boost::mp11::mp_fold<
65 ::boost::mp11::mp_transform< ::boost::type_erasure::detail::extract_concept_or_void, L1, L2>,
66 void,
67 ::boost::type_erasure::detail::combine_concepts_t
68 >;
69
70 #else
71
72 template<class T, class U>
73 struct maybe_extract_concept
74 {
75 typedef typename ::boost::mpl::eval_if<
76 ::boost::type_erasure::is_placeholder<
77 typename ::boost::remove_cv<
78 typename ::boost::remove_reference<T>::type
79 >::type
80 >,
81 ::boost::type_erasure::concept_of<typename ::boost::remove_reference<U>::type>,
82 ::boost::mpl::identity<void>
83 >::type type;
84 };
85
86 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
87
88 template<class Args, class... U>
89 struct extract_concept;
90
91 template<class R, class T0, class... T, class U0, class... U>
92 struct extract_concept<R(T0, T...), U0, U...>
93 {
94 typedef typename ::boost::type_erasure::detail::combine_concepts<
95 typename ::boost::type_erasure::detail::maybe_extract_concept<
96 T0, U0
97 >::type,
98 typename ::boost::type_erasure::detail::extract_concept<
99 void(T...),
100 U...
101 >::type
102 >::type type;
103 };
104
105 template<>
106 struct extract_concept<void()>
107 {
108 typedef void type;
109 };
110
111 #else
112
113 #define BOOST_PP_FILENAME_1 <boost/type_erasure/detail/extract_concept.hpp>
114 #define BOOST_PP_ITERATION_LIMITS (1, BOOST_TYPE_ERASURE_MAX_ARITY)
115 #include BOOST_PP_ITERATE()
116
117 #endif
118
119 #endif
120
121 }
122 }
123 }
124
125 #endif
126
127 #else
128
129 #define N BOOST_PP_ITERATION()
130
131 #define BOOST_TYPE_ERASURE_EXTRACT_CONCEPT(z, n, data) \
132 typedef typename ::boost::type_erasure::detail::combine_concepts< \
133 typename ::boost::type_erasure::detail::maybe_extract_concept< \
134 BOOST_PP_CAT(T, n), BOOST_PP_CAT(U, n) \
135 >::type, \
136 BOOST_PP_CAT(concept, n) \
137 >::type BOOST_PP_CAT(concept, BOOST_PP_INC(n));
138
139 template<
140 BOOST_PP_ENUM_PARAMS(N, class T),
141 BOOST_PP_ENUM_PARAMS(N, class U)>
142 struct BOOST_PP_CAT(extract_concept, N)
143 {
144 typedef void concept0;
145
146 BOOST_PP_REPEAT(N, BOOST_TYPE_ERASURE_EXTRACT_CONCEPT, ~)
147
148 typedef BOOST_PP_CAT(concept, N) type;
149 };
150
151 #undef BOOST_TYPE_ERASURE_EXTRACT_CONCEPT
152 #undef N
153
154 #endif