Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/type_erasure/is_subconcept.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Boost.TypeErasure library
0002 //
0003 // Copyright 2012 Steven Watanabe
0004 //
0005 // Distributed under the Boost Software License Version 1.0. (See
0006 // accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // $Id$
0010 
0011 #ifndef BOOST_TYPE_ERASURE_IS_SUBCONCEPT_HPP_INCLUDED
0012 #define BOOST_TYPE_ERASURE_IS_SUBCONCEPT_HPP_INCLUDED
0013 
0014 #include <boost/mpl/and.hpp>
0015 #include <boost/mpl/bool.hpp>
0016 #include <boost/mpl/not.hpp>
0017 #include <boost/mpl/if.hpp>
0018 #include <boost/mpl/end.hpp>
0019 #include <boost/mpl/find_if.hpp>
0020 #include <boost/mpl/has_key.hpp>
0021 #include <boost/type_traits/is_same.hpp>
0022 #include <boost/type_erasure/detail/normalize.hpp>
0023 #include <boost/type_erasure/detail/check_map.hpp>
0024 #include <boost/type_erasure/detail/rebind_placeholders.hpp>
0025 #include <boost/type_erasure/static_binding.hpp>
0026 
0027 namespace boost {
0028 namespace type_erasure {
0029 namespace detail {
0030 
0031 #ifdef BOOST_TYPE_ERASURE_USE_MP11
0032 
0033 template<class S, class K>
0034 struct mp_set_has_key : ::boost::mp11::mp_set_contains<S, K> {};
0035 
0036 template<class Super, class Bindings>
0037 struct is_subconcept_f
0038 {
0039     template<class T>
0040     using apply = ::boost::mp11::mp_set_contains<Super, ::boost::type_erasure::detail::rebind_placeholders_t<T, Bindings> >;
0041 };
0042 
0043 template<class Super>
0044 struct is_subconcept_f<Super, void>
0045 {
0046     template<class T>
0047     using apply = ::boost::mp11::mp_set_contains<Super, T>;
0048 };
0049 
0050 #endif
0051 
0052 template<class Sub, class Super, class PlaceholderMap>
0053 struct is_subconcept_impl {
0054 #ifndef BOOST_TYPE_ERASURE_USE_MP11
0055     typedef typename ::boost::type_erasure::detail::normalize_concept<
0056         Super>::concept_set super_set;
0057 
0058     typedef typename ::boost::type_erasure::detail::get_placeholder_normalization_map<
0059         Super
0060     >::type placeholder_subs_super;
0061     
0062     typedef typename ::boost::type_erasure::detail::normalize_concept<
0063         Sub>::type normalized_sub;
0064     typedef typename ::boost::type_erasure::detail::get_placeholder_normalization_map<
0065         Sub
0066     >::type placeholder_subs_sub;
0067 
0068     typedef typename ::boost::mpl::eval_if< ::boost::is_same<PlaceholderMap, void>,
0069         boost::mpl::identity<void>,
0070         ::boost::type_erasure::detail::convert_deductions<
0071             PlaceholderMap,
0072             placeholder_subs_sub,
0073             placeholder_subs_super
0074         >
0075     >::type bindings;
0076 
0077     typedef typename ::boost::mpl::if_< ::boost::is_same<PlaceholderMap, void>,
0078         ::boost::mpl::_1,
0079         ::boost::type_erasure::detail::rebind_placeholders<
0080             ::boost::mpl::_1,
0081             bindings
0082         >
0083     >::type transform;
0084 
0085     typedef typename ::boost::is_same<
0086         typename ::boost::mpl::find_if<normalized_sub,
0087             ::boost::mpl::not_<
0088                 ::boost::mpl::has_key<
0089                     super_set,
0090                     transform
0091                 >
0092             >
0093         >::type,
0094         typename ::boost::mpl::end<normalized_sub>::type
0095     >::type type;
0096 #else
0097     typedef ::boost::type_erasure::detail::normalize_concept_t<Super> super_set;
0098 
0099     typedef ::boost::type_erasure::detail::get_placeholder_normalization_map_t<
0100         Super
0101     > placeholder_subs_super;
0102     
0103     typedef ::boost::type_erasure::detail::normalize_concept_t<Sub> normalized_sub;
0104     typedef ::boost::type_erasure::detail::get_placeholder_normalization_map_t<
0105         Sub
0106     > placeholder_subs_sub;
0107     typedef ::boost::mp11::mp_eval_if_c< ::boost::is_same<PlaceholderMap, void>::value,
0108         void,
0109         ::boost::type_erasure::detail::convert_deductions_t,
0110         PlaceholderMap,
0111         placeholder_subs_sub,
0112         placeholder_subs_super
0113     > bindings;
0114 
0115     typedef typename ::boost::mp11::mp_all_of<
0116         normalized_sub,
0117         ::boost::type_erasure::detail::is_subconcept_f<super_set, bindings>::template apply
0118     > type;
0119 #endif
0120 };
0121 
0122 }
0123 
0124 /**
0125  * @ref is_subconcept is a boolean metafunction that determines whether
0126  * one concept is a sub-concept of another.
0127  *
0128  * \code
0129  * is_subconcept<incrementable<>, incrementable<> >             -> true
0130  * is_subconcept<incrementable<>, addable<> >                   -> false
0131  * is_subconcept<incrementable<_a>, forward_iterator<_iter>,
0132  *   mpl::map<mpl::pair<_a, _iter> > >                          -> true
0133  * \endcode
0134  *
0135  * \tparam Sub The sub concept
0136  * \tparam Super The super concept
0137  * \tparam PlaceholderMap (optional) An MPL map with keys for
0138  *   every non-deduced placeholder in Sub.  The
0139  *   associated value of each key is the corresponding placeholder
0140  *   in Super.  If @c PlaceholderMap is omitted, @c Super and @c Sub
0141  *   are presumed to use the same set of placeholders.
0142  */
0143 template<class Sub, class Super, class PlaceholderMap = void>
0144 struct is_subconcept :
0145     ::boost::mpl::and_<
0146         ::boost::type_erasure::detail::check_map<Sub, PlaceholderMap>,
0147         ::boost::type_erasure::detail::is_subconcept_impl<Sub, Super, PlaceholderMap>
0148     >::type
0149 {};
0150 
0151 #ifndef BOOST_TYPE_ERASURE_DOXYGEN
0152 template<class Sub, class Super>
0153 struct is_subconcept<Sub, Super, void> :
0154     ::boost::type_erasure::detail::is_subconcept_impl<Sub, Super, void>::type
0155 {};
0156 template<class Sub, class Super, class PlaceholderMap>
0157 struct is_subconcept<Sub, Super, static_binding<PlaceholderMap> > :
0158     ::boost::mpl::and_<
0159         ::boost::type_erasure::detail::check_map<Sub, PlaceholderMap>,
0160         ::boost::type_erasure::detail::is_subconcept_impl<Sub, Super, PlaceholderMap>
0161     >::type
0162 {};
0163 #endif
0164 
0165 }
0166 }
0167 
0168 #endif