summaryrefslogtreecommitdiff
path: root/boost/spirit/home/x3/support/ast/variant.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/spirit/home/x3/support/ast/variant.hpp')
-rw-r--r--boost/spirit/home/x3/support/ast/variant.hpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/boost/spirit/home/x3/support/ast/variant.hpp b/boost/spirit/home/x3/support/ast/variant.hpp
index cf626e88be..52e565d1d4 100644
--- a/boost/spirit/home/x3/support/ast/variant.hpp
+++ b/boost/spirit/home/x3/support/ast/variant.hpp
@@ -7,13 +7,10 @@
#if !defined(BOOST_SPIRIT_X3_VARIANT_AUGUST_6_2011_0859AM)
#define BOOST_SPIRIT_X3_VARIANT_AUGUST_6_2011_0859AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/variant.hpp>
#include <boost/mpl/list.hpp>
#include <boost/type_traits/is_base_of.hpp>
+#include <type_traits>
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace x3
@@ -126,17 +123,25 @@ namespace boost { namespace spirit { namespace x3
// tell spirit that this is an adapted variant
struct adapted_variant_tag;
- typedef boost::variant<Types...> variant_type;
- typedef mpl::list<typename detail::remove_forward<Types>::type...> types;
- typedef variant<Types...> base_type;
+ using variant_type = boost::variant<Types...>;
+ using types = mpl::list<typename detail::remove_forward<Types>::type...>;
+ using base_type = variant; // The current instantiation
+
+ template<typename T>
+ using non_self_t // used only for SFINAE checks below
+ = std::enable_if_t<!(std::is_base_of<base_type
+ ,std::remove_reference_t<T>
+ >
+ ::value)
+ >;
variant() : var() {}
- template <typename T, typename disable_if<is_base_of<base_type, T>>::type>
+ template <typename T, class = non_self_t<T>>
explicit variant(T const& rhs)
: var(rhs) {}
- template <typename T, typename disable_if<is_base_of<base_type, T>>::type>
+ template <typename T, class = non_self_t<T>>
explicit variant(T&& rhs)
: var(std::forward<T>(rhs)) {}
@@ -161,16 +166,14 @@ namespace boost { namespace spirit { namespace x3
return *this;
}
- template <typename T>
- //typename disable_if<is_base_of<base_type, T>, variant&>::type
+ template <typename T, class = non_self_t<T>>
variant& operator=(T const& rhs)
{
var = rhs;
return *this;
}
- template <typename T>
- //typename disable_if<is_base_of<base_type, T>, variant&>::type
+ template <typename T, class = non_self_t<T>>
variant& operator=(T&& rhs)
{
var = std::forward<T>(rhs);