1 //-----------------------------------------------------------------------------
2 // boost variant/detail/element_index.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
6 // Copyright (c) 2014-2015 Antony Polukhin
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)
12 #ifndef BOOST_VARIANT_DETAIL_ELEMENT_INDEX_HPP
13 #define BOOST_VARIANT_DETAIL_ELEMENT_INDEX_HPP
15 #include <boost/config.hpp>
16 #include <boost/variant/recursive_wrapper_fwd.hpp>
17 #include <boost/variant/variant_fwd.hpp>
19 #include <boost/type_traits/remove_cv.hpp>
20 #include <boost/type_traits/remove_reference.hpp>
21 #include <boost/mpl/find_if.hpp>
23 namespace boost { namespace detail { namespace variant {
25 template <class VariantElement, class T>
26 struct variant_element_functor :
28 boost::is_same<VariantElement, T>,
29 boost::is_same<VariantElement, boost::recursive_wrapper<T> >,
30 boost::is_same<VariantElement, T& >
34 template <class Types, class T>
35 struct element_iterator_impl :
39 variant_element_functor<boost::mpl::_1, T>,
40 variant_element_functor<boost::mpl::_1, typename boost::remove_cv<T>::type >
45 template <class Variant, class T>
46 struct element_iterator :
47 element_iterator_impl< typename Variant::types, typename boost::remove_reference<T>::type >
50 template <class Variant, class T>
51 struct holds_element :
54 typename boost::mpl::end<typename Variant::types>::type,
55 typename element_iterator<Variant, T>::type
61 }}} // namespace boost::detail::variant
63 #endif // BOOST_VARIANT_DETAIL_ELEMENT_INDEX_HPP