]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_erasure/include/boost/type_erasure/is_subconcept.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / type_erasure / include / boost / type_erasure / is_subconcept.hpp
1 // Boost.TypeErasure library
2 //
3 // Copyright 2012 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 #ifndef BOOST_TYPE_ERASURE_IS_SUBCONCEPT_HPP_INCLUDED
12 #define BOOST_TYPE_ERASURE_IS_SUBCONCEPT_HPP_INCLUDED
13
14 #include <boost/mpl/bool.hpp>
15 #include <boost/mpl/not.hpp>
16 #include <boost/mpl/if.hpp>
17 #include <boost/mpl/end.hpp>
18 #include <boost/mpl/find_if.hpp>
19 #include <boost/mpl/has_key.hpp>
20 #include <boost/type_traits/is_same.hpp>
21 #include <boost/type_erasure/detail/normalize.hpp>
22 #include <boost/type_erasure/detail/rebind_placeholders.hpp>
23 #include <boost/type_erasure/static_binding.hpp>
24
25 namespace boost {
26 namespace type_erasure {
27 namespace detail {
28
29 template<class Sub, class Super, class PlaceholderMap>
30 struct is_subconcept_impl {
31 typedef typename ::boost::type_erasure::detail::normalize_concept<
32 Super>::concept_set super_set;
33 typedef typename ::boost::type_erasure::detail::get_placeholder_normalization_map<
34 Super
35 >::type placeholder_subs_super;
36
37 typedef typename ::boost::type_erasure::detail::normalize_concept<
38 Sub>::type normalized_sub;
39 typedef typename ::boost::type_erasure::detail::get_placeholder_normalization_map<
40 Sub
41 >::type placeholder_subs_sub;
42
43 typedef typename ::boost::mpl::eval_if< ::boost::is_same<PlaceholderMap, void>,
44 boost::mpl::identity<void>,
45 ::boost::type_erasure::detail::convert_deductions<
46 PlaceholderMap,
47 placeholder_subs_sub,
48 placeholder_subs_super
49 >
50 >::type bindings;
51
52 typedef typename ::boost::mpl::if_< ::boost::is_same<PlaceholderMap, void>,
53 ::boost::mpl::_1,
54 ::boost::type_erasure::detail::rebind_placeholders<
55 ::boost::mpl::_1,
56 bindings
57 >
58 >::type transform;
59
60 typedef typename ::boost::is_same<
61 typename ::boost::mpl::find_if<normalized_sub,
62 ::boost::mpl::not_<
63 ::boost::mpl::has_key<
64 super_set,
65 transform
66 >
67 >
68 >::type,
69 typename ::boost::mpl::end<normalized_sub>::type
70 >::type type;
71 };
72
73 }
74
75 /**
76 * @ref is_subconcept is a boolean metafunction that determines whether
77 * one concept is a sub-concept of another.
78 *
79 * \code
80 * is_subconcept<incrementable<>, incrementable<> > -> true
81 * is_subconcept<incrementable<>, addable<> > -> false
82 * is_subconcept<incrementable<_a>, forward_iterator<_iter>,
83 * mpl::map<mpl::pair<_a, _iter> > > -> true
84 * \endcode
85 *
86 * \tparam Sub The sub concept
87 * \tparam Super The super concept
88 * \tparam PlaceholderMap (optional) An MPL map with keys for
89 * every non-deduced placeholder in Sub. The
90 * associated value of each key is the corresponding placeholder
91 * in Super. If @c PlaceholderMap is omitted, @c Super and @c Sub
92 * are presumed to use the same set of placeholders.
93 */
94 template<class Sub, class Super, class PlaceholderMap = void>
95 struct is_subconcept : ::boost::type_erasure::detail::is_subconcept_impl<Sub, Super, PlaceholderMap>::type {
96 };
97
98 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
99 template<class Sub, class Super, class PlaceholderMap>
100 struct is_subconcept<Sub, Super, static_binding<PlaceholderMap> > :
101 ::boost::type_erasure::detail::is_subconcept_impl<Sub, Super, PlaceholderMap>::type
102 {};
103 #endif
104
105 }
106 }
107
108 #endif