summaryrefslogtreecommitdiff
path: root/boost/variant/detail/element_index.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-03-21 15:45:20 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-03-21 15:46:37 +0900
commit733b5d5ae2c5d625211e2985ac25728ac3f54883 (patch)
treea5b214744b256f07e1dc2bd7273035a7808c659f /boost/variant/detail/element_index.hpp
parent08c1e93fa36a49f49325a07fe91ff92c964c2b6c (diff)
downloadboost-upstream/1.58.0.tar.gz
boost-upstream/1.58.0.tar.bz2
boost-upstream/1.58.0.zip
Imported Upstream version 1.58.0upstream/1.58.0
Change-Id: If0072143aa26874812e0db6872e1efb10a3e5e94 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/variant/detail/element_index.hpp')
-rw-r--r--boost/variant/detail/element_index.hpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/boost/variant/detail/element_index.hpp b/boost/variant/detail/element_index.hpp
new file mode 100644
index 0000000000..bd80bdd15c
--- /dev/null
+++ b/boost/variant/detail/element_index.hpp
@@ -0,0 +1,61 @@
+//-----------------------------------------------------------------------------
+// boost variant/detail/element_index.hpp header file
+// See http://www.boost.org for updates, documentation, and revision history.
+//-----------------------------------------------------------------------------
+//
+// Copyright (c) 2014-2015 Antony Polukhin
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_VARIANT_DETAIL_ELEMENT_INDEX_HPP
+#define BOOST_VARIANT_DETAIL_ELEMENT_INDEX_HPP
+
+#include "boost/config.hpp"
+#include "boost/variant/recursive_wrapper_fwd.hpp"
+#include "boost/variant/variant_fwd.hpp"
+
+#include "boost/mpl/find_if.hpp"
+
+namespace boost { namespace detail { namespace variant {
+
+template <class VariantElement, class T>
+struct variant_element_functor :
+ boost::mpl::or_<
+ boost::is_same<VariantElement, T>,
+ boost::is_same<VariantElement, boost::recursive_wrapper<T> >,
+ boost::is_same<VariantElement, T& >
+ >
+{};
+
+template <class Types, class T>
+struct element_iterator_impl :
+ boost::mpl::find_if<
+ Types,
+ boost::mpl::or_<
+ variant_element_functor<boost::mpl::_1, T>,
+ variant_element_functor<boost::mpl::_1, typename boost::remove_cv<T>::type >
+ >
+ >
+{};
+
+template <class Variant, class T>
+struct element_iterator :
+ element_iterator_impl< typename Variant::types, T>
+{};
+
+template <class Variant, class T>
+struct holds_element :
+ boost::mpl::not_<
+ boost::is_same<
+ typename boost::mpl::end<typename Variant::types>::type,
+ typename element_iterator<Variant, T>::type
+ >
+ >
+{};
+
+
+}}} // namespace boost::detail::variant
+
+#endif // BOOST_VARIANT_DETAIL_ELEMENT_INDEX_HPP