]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/type_erasure/detail/check_map.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / type_erasure / detail / check_map.hpp
CommitLineData
7c673cae
FG
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_DETAIL_CHECK_MAP_HPP_INCLUDED
12#define BOOST_TYPE_ERASURE_DETAIL_CHECK_MAP_HPP_INCLUDED
13
14#include <boost/mpl/not.hpp>
15#include <boost/mpl/or.hpp>
16#include <boost/mpl/bool.hpp>
17#include <boost/mpl/set.hpp>
18#include <boost/mpl/has_key.hpp>
19#include <boost/mpl/find_if.hpp>
20#include <boost/mpl/fold.hpp>
21#include <boost/mpl/end.hpp>
22#include <boost/type_traits/is_same.hpp>
23#include <boost/type_erasure/detail/get_placeholders.hpp>
24#include <boost/type_erasure/detail/normalize.hpp>
25#include <boost/type_erasure/deduced.hpp>
26#include <boost/type_erasure/static_binding.hpp>
27
28namespace boost {
29namespace type_erasure {
30namespace detail {
31
32template<class T>
33struct is_deduced : boost::mpl::false_ {};
34template<class T>
35struct is_deduced< ::boost::type_erasure::deduced<T> > : boost::mpl::true_ {};
36
37// returns true if Map has a key for every non-deduced placeholder in Concept
38template<class Concept, class Map>
39struct check_map {
11fdf7f2 40#ifndef BOOST_TYPE_ERASURE_USE_MP11
7c673cae 41 typedef typename normalize_concept<Concept>::basic basic_components;
11fdf7f2
TL
42
43 typedef typename ::boost::mpl::fold<
44 basic_components,
45 ::boost::mpl::set0<>,
46 ::boost::type_erasure::detail::get_placeholders<
47 ::boost::mpl::_2,
48 ::boost::mpl::_1
49 >
50 >::type placeholders;
51
7c673cae
FG
52 // Every non-deduced placeholder referenced in this
53 // map is indirectly deduced.
54 typedef typename ::boost::type_erasure::detail::get_placeholder_normalization_map<
55 Concept>::type placeholder_subs;
56 typedef typename ::boost::mpl::fold<
57 placeholder_subs,
58 ::boost::mpl::set0<>,
59 ::boost::mpl::insert<
60 ::boost::mpl::_1,
61 ::boost::mpl::second< ::boost::mpl::_2>
62 >
63 >::type indirect_deduced_placeholders;
7c673cae
FG
64 typedef typename ::boost::is_same<
65 typename ::boost::mpl::find_if<
66 placeholders,
67 ::boost::mpl::not_<
68 ::boost::mpl::or_<
69 ::boost::type_erasure::detail::is_deduced< ::boost::mpl::_1>,
70 ::boost::mpl::has_key<Map, ::boost::mpl::_1>,
71 ::boost::mpl::has_key<indirect_deduced_placeholders, ::boost::mpl::_1>
72 >
73 >
74 >::type,
75 typename ::boost::mpl::end<placeholders>::type
76 >::type type;
11fdf7f2
TL
77
78#else
79 typedef ::boost::type_erasure::detail::get_all_placeholders<
80 ::boost::type_erasure::detail::normalize_concept_t<Concept>
81 > placeholders;
82
83 // Every non-deduced placeholder referenced in this
84 // map is indirectly deduced.
85 typedef typename ::boost::type_erasure::detail::get_placeholder_normalization_map<
86 Concept>::type placeholder_subs;
87 typedef ::boost::mp11::mp_unique<
88 ::boost::mp11::mp_append<
89 ::boost::mp11::mp_transform<
90 ::boost::mp11::mp_first,
91 ::boost::type_erasure::detail::make_mp_list<Map>
92 >,
93 ::boost::mp11::mp_transform<
94 ::boost::mp11::mp_second,
95 ::boost::type_erasure::detail::make_mp_list<placeholder_subs>
96 >
97 >
98 > okay_placeholders;
99 template<class P>
100 using check_placeholder = ::boost::mpl::or_<
101 ::boost::type_erasure::detail::is_deduced<P>,
102 ::boost::mp11::mp_set_contains<okay_placeholders, P>
103 >;
104 typedef ::boost::mp11::mp_all_of<placeholders, check_placeholder> type;
105#endif
7c673cae
FG
106};
107
108template<class Concept, class Map>
109struct check_map<Concept, ::boost::type_erasure::static_binding<Map> > :
110 check_map<Concept, Map>
111{};
112
113}
114}
115}
116
117#endif