]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/variant/include/boost/variant/detail/element_index.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / variant / include / boost / variant / detail / element_index.hpp
1 //-----------------------------------------------------------------------------
2 // boost variant/detail/element_index.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
5 //
6 // Copyright (c) 2014-2015 Antony Polukhin
7 //
8 // Distributed under the Boost Software License, Version 1.0. (See
9 // accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
11
12 #ifndef BOOST_VARIANT_DETAIL_ELEMENT_INDEX_HPP
13 #define BOOST_VARIANT_DETAIL_ELEMENT_INDEX_HPP
14
15 #include <boost/config.hpp>
16 #include <boost/variant/recursive_wrapper_fwd.hpp>
17 #include <boost/variant/variant_fwd.hpp>
18
19 #include <boost/type_traits/remove_cv.hpp>
20 #include <boost/type_traits/remove_reference.hpp>
21 #include <boost/mpl/find_if.hpp>
22
23 namespace boost { namespace detail { namespace variant {
24
25 template <class VariantElement, class T>
26 struct variant_element_functor :
27 boost::mpl::or_<
28 boost::is_same<VariantElement, T>,
29 boost::is_same<VariantElement, boost::recursive_wrapper<T> >,
30 boost::is_same<VariantElement, T& >
31 >
32 {};
33
34 template <class Types, class T>
35 struct element_iterator_impl :
36 boost::mpl::find_if<
37 Types,
38 boost::mpl::or_<
39 variant_element_functor<boost::mpl::_1, T>,
40 variant_element_functor<boost::mpl::_1, typename boost::remove_cv<T>::type >
41 >
42 >
43 {};
44
45 template <class Variant, class T>
46 struct element_iterator :
47 element_iterator_impl< typename Variant::types, typename boost::remove_reference<T>::type >
48 {};
49
50 template <class Variant, class T>
51 struct holds_element :
52 boost::mpl::not_<
53 boost::is_same<
54 typename boost::mpl::end<typename Variant::types>::type,
55 typename element_iterator<Variant, T>::type
56 >
57 >
58 {};
59
60
61 }}} // namespace boost::detail::variant
62
63 #endif // BOOST_VARIANT_DETAIL_ELEMENT_INDEX_HPP