mirror of
https://github.com/boostorg/variant.git
synced 2026-07-21 13:43:36 +00:00
Drop C++03 support (#107)
Drop boost::move and boost::bind dependencies. Use Boost.PP in less cases
This commit is contained in:
@@ -13,13 +13,11 @@ target_include_directories( boost_variant INTERFACE include )
|
||||
target_link_libraries( boost_variant
|
||||
INTERFACE
|
||||
Boost::assert
|
||||
Boost::bind
|
||||
Boost::config
|
||||
Boost::container_hash
|
||||
Boost::core
|
||||
Boost::detail
|
||||
Boost::integer
|
||||
Boost::move
|
||||
Boost::mpl
|
||||
Boost::preprocessor
|
||||
Boost::static_assert
|
||||
|
||||
@@ -91,8 +91,6 @@
|
||||
<code><functionname>apply_visitor</functionname></code> on the
|
||||
stored visitor using the given operands.</simpara>
|
||||
</description>
|
||||
<notes>Version with variadic templates is used by default if
|
||||
<macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname> is not defined.</notes>
|
||||
</overloaded-method>
|
||||
</method-group>
|
||||
</class>
|
||||
@@ -111,8 +109,7 @@
|
||||
<simpara>See <code><classname>apply_visitor_delayed_t</classname></code>
|
||||
which is used when <code>Visitor</code> has <code>result_type</code>
|
||||
typedef.</simpara>
|
||||
<simpara>Available only if macro
|
||||
<macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname> is not defined and
|
||||
<simpara>Available only if
|
||||
compiler supports <code>decltype(auto)</code> and <code>decltype(some-expression)</code>.</simpara>
|
||||
</description>
|
||||
|
||||
|
||||
@@ -13,22 +13,6 @@
|
||||
<para>Provides declarations of <functionname>apply_visitor</functionname> for three or more
|
||||
<code><classname>variant</classname></code> parameters.</para>
|
||||
|
||||
<macro name="BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS">
|
||||
<purpose>
|
||||
<simpara>Controls maximum amount of <code><classname>variant</classname></code>
|
||||
parameters for multi visistors. Not used when <code>std::tuple</code> is available and
|
||||
<code><macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname></code>
|
||||
is not defined.</simpara>
|
||||
</purpose>
|
||||
|
||||
<description>
|
||||
<para><emphasis role="bold">Note</emphasis>: Default amount is 4. Define it
|
||||
to bigger value before including <boost/variant/multivisitors.hpp> to
|
||||
increase maximum amount of <code><classname>variant</classname></code>
|
||||
parameters for <functionname>apply_visitor</functionname>.</para>
|
||||
</description>
|
||||
</macro>
|
||||
|
||||
<namespace name="boost">
|
||||
<overloaded-function name="apply_visitor /*three or more variant parameters*/">
|
||||
<description>
|
||||
|
||||
@@ -19,36 +19,6 @@
|
||||
class templates and the <code>boost::recursive_variant_</code> tag type.
|
||||
Also defines several preprocessor symbols, as described below.</para>
|
||||
|
||||
<macro name="BOOST_VARIANT_LIMIT_TYPES">
|
||||
<purpose>
|
||||
<simpara>Expands to the length of the
|
||||
template parameter list for
|
||||
<code><classname>variant</classname></code>. Not used if
|
||||
<code><macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname></code>
|
||||
is not defined.
|
||||
</simpara>
|
||||
</purpose>
|
||||
|
||||
<description>
|
||||
<para><emphasis role="bold">Note</emphasis>: Conforming
|
||||
implementations of <code>variant</code> must allow at least ten
|
||||
template arguments. That is, BOOST_VARIANT_LIMIT_TYPES must be greater
|
||||
or equal to <code>10</code>.</para>
|
||||
</description>
|
||||
</macro>
|
||||
|
||||
<macro name="BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES">
|
||||
<purpose>
|
||||
<simpara>If this macro is defined, then library won't use C++11 variadic templates.
|
||||
Users may define this macro to make
|
||||
<code><macroname>BOOST_VARIANT_ENUM_PARAMS</macroname></code>
|
||||
and <code><macroname>BOOST_VARIANT_ENUM_SHIFTED_PARAMS</macroname></code> expand
|
||||
to a comma-separated sequence instead of variadic templates. Define this macro if
|
||||
your compiler has problems with compilation of variadic templates.
|
||||
</simpara>
|
||||
</purpose>
|
||||
</macro>
|
||||
|
||||
<macro name="BOOST_VARIANT_ENUM_PARAMS" kind="functionlike">
|
||||
<macro-parameter name="param"/>
|
||||
|
||||
@@ -58,9 +28,7 @@
|
||||
</purpose>
|
||||
|
||||
<description>
|
||||
<para> When variadic templates are available and
|
||||
<code><macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname></code>
|
||||
is not defined, expands to variadic template list in the following manner:
|
||||
<para> Expands to variadic template list in the following manner:
|
||||
<code><programlisting>
|
||||
BOOST_VARIANT_ENUM_PARAMS(T) => T0, TN...
|
||||
BOOST_VARIANT_ENUM_PARAMS(class T) => class T0, class... TN
|
||||
@@ -97,9 +65,7 @@
|
||||
</purpose>
|
||||
|
||||
<description>
|
||||
<para> When variadic templates are available and
|
||||
<code><macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname></code>
|
||||
is not defined, expands to variadic template list in the following manner:
|
||||
<para> Expands to variadic template list in the following manner:
|
||||
<code><programlisting>
|
||||
BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T) => TN...
|
||||
BOOST_VARIANT_ENUM_SHIFTED_PARAMS(class T) => class... TN
|
||||
|
||||
@@ -407,12 +407,6 @@ assert(
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
<para>Finally, we must note that multi visitation does not support
|
||||
"delayed" form of
|
||||
<code><functionname>apply_visitor</functionname> if
|
||||
<macroname>BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES</macroname> is defined</code>.
|
||||
</para>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
@@ -21,12 +21,10 @@
|
||||
# include <boost/variant/detail/has_result_type.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
# include <boost/core/enable_if.hpp>
|
||||
# include <boost/type_traits/is_lvalue_reference.hpp>
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
# include <boost/move/utility_core.hpp> // for boost::move, boost::forward
|
||||
#endif
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/type_traits/is_lvalue_reference.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -63,33 +61,20 @@ public: // structors
|
||||
|
||||
public: // visitor interfaces
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
template <typename Value2>
|
||||
typename enable_if_c<MoveSemantics && is_same<Value2, Value2>::value, result_type>::type
|
||||
operator()(Value2&& value2)
|
||||
{
|
||||
return visitor_(::boost::move(value1_), ::boost::forward<Value2>(value2));
|
||||
return visitor_(std::move(value1_), std::forward<Value2>(value2));
|
||||
}
|
||||
|
||||
template <typename Value2>
|
||||
typename disable_if_c<MoveSemantics && is_same<Value2, Value2>::value, result_type>::type
|
||||
operator()(Value2&& value2)
|
||||
{
|
||||
return visitor_(value1_, ::boost::forward<Value2>(value2));
|
||||
return visitor_(value1_, std::forward<Value2>(value2));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template <typename Value2>
|
||||
result_type
|
||||
operator()(Value2& value2)
|
||||
{
|
||||
return visitor_(value1_, value2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
apply_visitor_binary_invoke& operator=(const apply_visitor_binary_invoke&);
|
||||
};
|
||||
@@ -117,8 +102,6 @@ public: // structors
|
||||
|
||||
public: // visitor interfaces
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
template <typename Value1>
|
||||
typename enable_if_c<MoveSemantics && is_same<Value1, Value1>::value, result_type>::type
|
||||
operator()(Value1&& value1)
|
||||
@@ -129,7 +112,7 @@ public: // visitor interfaces
|
||||
, ! ::boost::is_lvalue_reference<Value1>::value
|
||||
> invoker(visitor_, value1);
|
||||
|
||||
return boost::apply_visitor(invoker, ::boost::move(visitable2_));
|
||||
return boost::apply_visitor(invoker, std::move(visitable2_));
|
||||
}
|
||||
|
||||
template <typename Value1>
|
||||
@@ -145,23 +128,6 @@ public: // visitor interfaces
|
||||
return boost::apply_visitor(invoker, visitable2_);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template <typename Value1>
|
||||
result_type
|
||||
operator()(Value1& value1)
|
||||
{
|
||||
apply_visitor_binary_invoke<
|
||||
Visitor
|
||||
, Value1
|
||||
, false
|
||||
> invoker(visitor_, value1);
|
||||
|
||||
return boost::apply_visitor(invoker, visitable2_);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
apply_visitor_binary_unwrap& operator=(const apply_visitor_binary_unwrap&);
|
||||
|
||||
@@ -173,8 +139,6 @@ private:
|
||||
// nonconst-visitor version:
|
||||
//
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
template <typename Visitor, typename Visitable1, typename Visitable2>
|
||||
inline typename Visitor::result_type
|
||||
apply_visitor( Visitor& visitor, Visitable1&& visitable1, Visitable2&& visitable2)
|
||||
@@ -183,29 +147,13 @@ apply_visitor( Visitor& visitor, Visitable1&& visitable1, Visitable2&& visitable
|
||||
Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
|
||||
> unwrapper(visitor, visitable2);
|
||||
|
||||
return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
|
||||
return boost::apply_visitor(unwrapper, std::forward<Visitable1>(visitable1));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template <typename Visitor, typename Visitable1, typename Visitable2>
|
||||
inline typename Visitor::result_type
|
||||
apply_visitor( Visitor& visitor, Visitable1& visitable1, Visitable2& visitable2)
|
||||
{
|
||||
::boost::detail::variant::apply_visitor_binary_unwrap<
|
||||
Visitor, Visitable2, false
|
||||
> unwrapper(visitor, visitable2);
|
||||
|
||||
return boost::apply_visitor(unwrapper, visitable1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// const-visitor version:
|
||||
//
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
template <typename Visitor, typename Visitable1, typename Visitable2>
|
||||
inline typename Visitor::result_type
|
||||
@@ -215,24 +163,9 @@ apply_visitor( const Visitor& visitor , Visitable1&& visitable1 , Visitable2&& v
|
||||
const Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
|
||||
> unwrapper(visitor, visitable2);
|
||||
|
||||
return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
|
||||
return boost::apply_visitor(unwrapper, std::forward<Visitable1>(visitable1));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template <typename Visitor, typename Visitable1, typename Visitable2>
|
||||
inline typename Visitor::result_type
|
||||
apply_visitor( const Visitor& visitor , Visitable1& visitable1 , Visitable2& visitable2)
|
||||
{
|
||||
::boost::detail::variant::apply_visitor_binary_unwrap<
|
||||
const Visitor, Visitable2, false
|
||||
> unwrapper(visitor, visitable2);
|
||||
|
||||
return boost::apply_visitor(unwrapper, visitable1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
|
||||
@@ -263,13 +196,13 @@ public: // visitor interfaces
|
||||
template <typename Value2>
|
||||
decltype(auto) operator()(Value2&& value2, typename enable_if_c<MoveSemantics && is_same<Value2, Value2>::value, bool>::type = true)
|
||||
{
|
||||
return visitor_(::boost::move(value1_), ::boost::forward<Value2>(value2));
|
||||
return visitor_(std::move(value1_), std::forward<Value2>(value2));
|
||||
}
|
||||
|
||||
template <typename Value2>
|
||||
decltype(auto) operator()(Value2&& value2, typename disable_if_c<MoveSemantics && is_same<Value2, Value2>::value, bool>::type = true)
|
||||
{
|
||||
return visitor_(value1_, ::boost::forward<Value2>(value2));
|
||||
return visitor_(value1_, std::forward<Value2>(value2));
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -301,7 +234,7 @@ public: // visitor interfaces
|
||||
, ! ::boost::is_lvalue_reference<Value1>::value
|
||||
> invoker(visitor_, value1);
|
||||
|
||||
return boost::apply_visitor(invoker, ::boost::move(visitable2_));
|
||||
return boost::apply_visitor(invoker, std::move(visitable2_));
|
||||
}
|
||||
|
||||
template <typename Value1>
|
||||
@@ -333,7 +266,7 @@ inline decltype(auto) apply_visitor(Visitor& visitor, Visitable1&& visitable1, V
|
||||
Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
|
||||
> unwrapper(visitor, visitable2);
|
||||
|
||||
return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
|
||||
return boost::apply_visitor(unwrapper, std::forward<Visitable1>(visitable1));
|
||||
}
|
||||
|
||||
template <typename Visitor, typename Visitable1, typename Visitable2>
|
||||
@@ -347,7 +280,7 @@ inline decltype(auto) apply_visitor(const Visitor& visitor, Visitable1&& visitab
|
||||
const Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
|
||||
> unwrapper(visitor, visitable2);
|
||||
|
||||
return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
|
||||
return boost::apply_visitor(unwrapper, std::forward<Visitable1>(visitable1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include <boost/variant/detail/apply_visitor_unary.hpp>
|
||||
#include <boost/variant/detail/apply_visitor_binary.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp> // for BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
|
||||
#include <boost/variant/detail/has_result_type.hpp>
|
||||
@@ -57,8 +57,6 @@ public: // structors
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
public: // N-ary visitor interface
|
||||
template <typename... Visitables>
|
||||
result_type operator()(Visitables&... visitables) const
|
||||
@@ -66,26 +64,6 @@ public: // N-ary visitor interface
|
||||
return apply_visitor(visitor_, visitables...);
|
||||
}
|
||||
|
||||
#else // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
public: // unary visitor interface
|
||||
|
||||
template <typename Visitable>
|
||||
result_type operator()(Visitable& visitable) const
|
||||
{
|
||||
return apply_visitor(visitor_, visitable);
|
||||
}
|
||||
|
||||
public: // binary visitor interface
|
||||
|
||||
template <typename Visitable1, typename Visitable2>
|
||||
result_type operator()(Visitable1& visitable1, Visitable2& visitable2) const
|
||||
{
|
||||
return apply_visitor(visitor_, visitable1, visitable2);
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
private:
|
||||
apply_visitor_delayed_t& operator=(const apply_visitor_delayed_t&);
|
||||
|
||||
@@ -100,8 +78,7 @@ inline typename boost::enable_if<
|
||||
return apply_visitor_delayed_t<Visitor>(visitor);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276) \
|
||||
&& !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO)
|
||||
|
||||
template <typename Visitor>
|
||||
class apply_visitor_delayed_cpp14_t
|
||||
@@ -137,8 +114,7 @@ inline typename boost::disable_if<
|
||||
return apply_visitor_delayed_cpp14_t<Visitor>(visitor);
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
// && !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
#endif // !defined(BOOST_NO_CXX14_DECLTYPE_AUTO)
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#define BOOST_VARIANT_DETAIL_APPLY_VISITOR_UNARY_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <utility>
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
# include <boost/mpl/distance.hpp>
|
||||
@@ -40,41 +40,23 @@ namespace boost {
|
||||
// nonconst-visitor version:
|
||||
//
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <typename Visitor, typename Visitable>
|
||||
inline typename Visitor::result_type
|
||||
apply_visitor(Visitor& visitor, Visitable&& visitable)
|
||||
{
|
||||
return ::boost::forward<Visitable>(visitable).apply_visitor(visitor);
|
||||
return std::forward<Visitable>(visitable).apply_visitor(visitor);
|
||||
}
|
||||
#else
|
||||
template <typename Visitor, typename Visitable>
|
||||
inline typename Visitor::result_type
|
||||
apply_visitor(Visitor& visitor, Visitable& visitable)
|
||||
{
|
||||
return visitable.apply_visitor(visitor);
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// const-visitor version:
|
||||
//
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <typename Visitor, typename Visitable>
|
||||
inline typename Visitor::result_type
|
||||
apply_visitor(const Visitor& visitor, Visitable&& visitable)
|
||||
{
|
||||
return ::boost::forward<Visitable>(visitable).apply_visitor(visitor);
|
||||
return std::forward<Visitable>(visitable).apply_visitor(visitor);
|
||||
}
|
||||
#else
|
||||
template <typename Visitor, typename Visitable>
|
||||
inline typename Visitor::result_type
|
||||
apply_visitor(const Visitor& visitor, Visitable& visitable)
|
||||
{
|
||||
return visitable.apply_visitor(visitor);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
@@ -116,12 +98,12 @@ struct result_wrapper1
|
||||
|
||||
Visitor&& visitor_;
|
||||
explicit result_wrapper1(Visitor&& visitor) BOOST_NOEXCEPT
|
||||
: visitor_(::boost::forward<Visitor>(visitor))
|
||||
: visitor_(std::forward<Visitor>(visitor))
|
||||
{}
|
||||
|
||||
template <class T>
|
||||
result_type operator()(T&& val) const {
|
||||
return visitor_(::boost::forward<T>(val));
|
||||
return visitor_(std::forward<T>(val));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -134,8 +116,8 @@ inline decltype(auto) apply_visitor(Visitor&& visitor, Visitable&& visitable,
|
||||
bool
|
||||
>::type = true)
|
||||
{
|
||||
boost::detail::variant::result_wrapper1<Visitor, Visitable> cpp14_vis(::boost::forward<Visitor>(visitor));
|
||||
return ::boost::forward<Visitable>(visitable).apply_visitor(cpp14_vis);
|
||||
boost::detail::variant::result_wrapper1<Visitor, Visitable> cpp14_vis(std::forward<Visitor>(visitor));
|
||||
return std::forward<Visitable>(visitable).apply_visitor(cpp14_vis);
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
|
||||
@@ -16,22 +16,4 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \
|
||||
defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) || \
|
||||
defined(BOOST_NO_CXX11_CONSTEXPR) || \
|
||||
defined(BOOST_NO_CXX11_NULLPTR) || \
|
||||
defined(BOOST_NO_CXX11_NOEXCEPT) || \
|
||||
defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || \
|
||||
defined(BOOST_NO_CXX11_FINAL) || \
|
||||
defined(BOOST_NO_CXX11_ALIGNOF) || \
|
||||
defined(BOOST_NO_CXX11_STATIC_ASSERT) || \
|
||||
defined(BOOST_NO_CXX11_SMART_PTR) || \
|
||||
defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) || \
|
||||
defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("C++03 support is deprecated in Boost.Variant 1.82 and will be removed in Boost.Variant 1.84.")
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_CONFIG_HPP
|
||||
|
||||
@@ -36,42 +36,10 @@
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
|
||||
#if !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
# define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL(T,Dest,Source) \
|
||||
substitute< T , Dest , Source > \
|
||||
/**/
|
||||
|
||||
#else // defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) class template rebind1
|
||||
//
|
||||
// Limited workaround in case 'substitute' metafunction unavailable.
|
||||
//
|
||||
|
||||
template <typename T, typename U1>
|
||||
struct rebind1
|
||||
{
|
||||
private:
|
||||
typedef typename mpl::lambda<
|
||||
mpl::identity<T>
|
||||
>::type le_;
|
||||
|
||||
public:
|
||||
typedef typename mpl::eval_if<
|
||||
is_same< le_, mpl::identity<T> >
|
||||
, le_ // identity<T>
|
||||
, mpl::apply1<le_, U1>
|
||||
>::type type;
|
||||
};
|
||||
|
||||
# define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL(T,Dest,Source) \
|
||||
rebind1< T , Dest > \
|
||||
/**/
|
||||
|
||||
#endif // !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction enable_recursive
|
||||
//
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/enum.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
namespace boost { namespace detail { namespace variant {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction make_variant_list
|
||||
@@ -32,42 +31,12 @@ namespace detail { namespace variant {
|
||||
// declaration workaround (below).
|
||||
//
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
template < typename... T >
|
||||
struct make_variant_list
|
||||
{
|
||||
typedef typename mpl::list< T... >::type type;
|
||||
};
|
||||
|
||||
#else // defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
template < BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
struct make_variant_list
|
||||
{
|
||||
public: // metafunction result
|
||||
|
||||
// [Define a macro to convert any void(NN) tags to mpl::void...]
|
||||
# define BOOST_VARIANT_AUX_CONVERT_VOID(z, N,_) \
|
||||
typename convert_void< BOOST_PP_CAT(T,N) >::type
|
||||
|
||||
// [...so that the specified types can be passed to mpl::list...]
|
||||
typedef typename mpl::list<
|
||||
BOOST_PP_ENUM(
|
||||
BOOST_VARIANT_LIMIT_TYPES
|
||||
, BOOST_VARIANT_AUX_CONVERT_VOID
|
||||
, _
|
||||
)
|
||||
>::type type;
|
||||
|
||||
// [...and, finally, the conversion macro can be undefined:]
|
||||
# undef BOOST_VARIANT_AUX_CONVERT_VOID
|
||||
|
||||
};
|
||||
|
||||
#endif // BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES workaround
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
}}} // namespace boost::detail::variant
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_MAKE_VARIANT_LIST_HPP
|
||||
|
||||
@@ -22,12 +22,11 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/move/utility_core.hpp> // for boost::move
|
||||
#include <boost/move/adl_move_swap.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace boost { namespace detail { namespace variant {
|
||||
|
||||
using boost::move;
|
||||
using std::move;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// function template move_swap
|
||||
@@ -39,7 +38,8 @@ using boost::move;
|
||||
template <typename T>
|
||||
inline void move_swap(T& lhs, T& rhs)
|
||||
{
|
||||
::boost::adl_move_swap(lhs, rhs);
|
||||
using std::swap;
|
||||
swap(lhs, rhs);
|
||||
}
|
||||
|
||||
}}} // namespace boost::detail::variant
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2013-2014.
|
||||
// Copyright Antony Polukhin, 2013-2023.
|
||||
//
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
@@ -17,15 +17,10 @@
|
||||
#endif
|
||||
|
||||
#include <boost/variant/detail/apply_visitor_unary.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp> // for BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
#include <boost/type_traits/is_lvalue_reference.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
|
||||
#if defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
# error "This file requires <tuple> and variadic templates support"
|
||||
#endif
|
||||
|
||||
#include <tuple>
|
||||
|
||||
namespace boost {
|
||||
@@ -64,7 +59,7 @@ namespace detail { namespace variant {
|
||||
typename enable_if_c<Wrapper::MoveSemantics, typename Wrapper::T>::type
|
||||
unwrap(Wrapper& w)
|
||||
{
|
||||
return ::boost::move(w.v);
|
||||
return std::move(w.v);
|
||||
}
|
||||
|
||||
template <typename Wrapper>
|
||||
@@ -189,7 +184,7 @@ namespace detail { namespace variant {
|
||||
),
|
||||
std::tuple<>()
|
||||
),
|
||||
::boost::forward<T1>(v1)
|
||||
std::forward<T1>(v1)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -207,7 +202,7 @@ namespace detail { namespace variant {
|
||||
),
|
||||
std::tuple<>()
|
||||
),
|
||||
::boost::forward<T1>(v1)
|
||||
std::forward<T1>(v1)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace detail { namespace variant {
|
||||
),
|
||||
std::tuple<>()
|
||||
),
|
||||
::boost::forward<T1>(v1)
|
||||
std::forward<T1>(v1)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace detail { namespace variant {
|
||||
),
|
||||
std::tuple<>()
|
||||
),
|
||||
::boost::forward<T1>(v1)
|
||||
std::forward<T1>(v1)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
// Boost.Varaint
|
||||
// Contains multivisitors that are implemented via preprocessor magic
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2013-2014.
|
||||
//
|
||||
// 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_MULTIVISITORS_PREPROCESSOR_BASED_HPP
|
||||
#define BOOST_VARIANT_DETAIL_MULTIVISITORS_PREPROCESSOR_BASED_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include <boost/preprocessor/repetition.hpp>
|
||||
#include <boost/preprocessor/punctuation/comma_if.hpp>
|
||||
#include <boost/preprocessor/arithmetic/add.hpp>
|
||||
#include <boost/preprocessor/arithmetic/sub.hpp>
|
||||
|
||||
#ifndef BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS
|
||||
# define BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS 4
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail { namespace variant {
|
||||
|
||||
template <class VisitorT, class Visitable1T, class Visitable2T>
|
||||
struct two_variables_holder {
|
||||
private:
|
||||
VisitorT& visitor_;
|
||||
Visitable1T& visitable1_;
|
||||
Visitable2T& visitable2_;
|
||||
|
||||
// required to suppress warnings and ensure that we do not copy
|
||||
// this visitor
|
||||
two_variables_holder& operator=(const two_variables_holder&);
|
||||
|
||||
public:
|
||||
typedef BOOST_DEDUCED_TYPENAME VisitorT::result_type result_type;
|
||||
|
||||
explicit two_variables_holder(VisitorT& visitor, Visitable1T& visitable1, Visitable2T& visitable2) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
, visitable1_(visitable1)
|
||||
, visitable2_(visitable2)
|
||||
{}
|
||||
|
||||
#define BOOST_VARIANT_OPERATOR_BEG() \
|
||||
return ::boost::apply_visitor( \
|
||||
::boost::bind<result_type>(boost::ref(visitor_), _1, _2 \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_OPERATOR_END() \
|
||||
), visitable1_, visitable2_); \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARANT_VISITORS_VARIABLES_PRINTER(z, n, data) \
|
||||
BOOST_PP_COMMA() boost::ref( BOOST_PP_CAT(vis, n) ) \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_VISIT(z, n, data) \
|
||||
template <BOOST_PP_ENUM_PARAMS(BOOST_PP_ADD(n, 1), class VisitableUnwrapped)> \
|
||||
result_type operator()( \
|
||||
BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ADD(n, 1), VisitableUnwrapped, & vis) \
|
||||
) const \
|
||||
{ \
|
||||
BOOST_VARIANT_OPERATOR_BEG() \
|
||||
BOOST_PP_REPEAT(BOOST_PP_ADD(n, 1), BOOST_VARANT_VISITORS_VARIABLES_PRINTER, ~) \
|
||||
BOOST_VARIANT_OPERATOR_END() \
|
||||
} \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT( BOOST_PP_SUB(BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS, 2), BOOST_VARIANT_VISIT, ~)
|
||||
#undef BOOST_VARIANT_OPERATOR_BEG
|
||||
#undef BOOST_VARIANT_OPERATOR_END
|
||||
#undef BOOST_VARANT_VISITORS_VARIABLES_PRINTER
|
||||
#undef BOOST_VARIANT_VISIT
|
||||
|
||||
};
|
||||
|
||||
template <class VisitorT, class Visitable1T, class Visitable2T>
|
||||
inline two_variables_holder<VisitorT, Visitable1T, Visitable2T> make_two_variables_holder(
|
||||
VisitorT& visitor, Visitable1T& visitable1, Visitable2T& visitable2
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
return two_variables_holder<VisitorT, Visitable1T, Visitable2T>(visitor, visitable1, visitable2);
|
||||
}
|
||||
|
||||
template <class VisitorT, class Visitable1T, class Visitable2T>
|
||||
inline two_variables_holder<const VisitorT, Visitable1T, Visitable2T> make_two_variables_holder(
|
||||
const VisitorT& visitor, Visitable1T& visitable1, Visitable2T& visitable2
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
return two_variables_holder<const VisitorT, Visitable1T, Visitable2T>(visitor, visitable1, visitable2);
|
||||
}
|
||||
|
||||
}} // namespace detail::variant
|
||||
|
||||
#define BOOST_VARIANT_APPLY_VISITOR_BEG() \
|
||||
return ::boost::apply_visitor( \
|
||||
boost::detail::variant::make_two_variables_holder(visitor, var0 , var1), \
|
||||
var2 \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_APPLY_VISITOR_END() \
|
||||
); \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARANT_VISITORS_VARIABLES_PRINTER(z, n, data) \
|
||||
BOOST_PP_COMMA() BOOST_PP_CAT(var, BOOST_PP_ADD(n, 3)) \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_VISIT(z, n, data) \
|
||||
template <class Visitor BOOST_PP_COMMA() BOOST_PP_ENUM_PARAMS(BOOST_PP_ADD(n, 3), class T)> \
|
||||
inline BOOST_DEDUCED_TYPENAME Visitor::result_type apply_visitor( \
|
||||
data BOOST_PP_COMMA() BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ADD(n, 3), T, & var) \
|
||||
) \
|
||||
{ \
|
||||
BOOST_VARIANT_APPLY_VISITOR_BEG() \
|
||||
BOOST_PP_REPEAT(n, BOOST_VARANT_VISITORS_VARIABLES_PRINTER, ~) \
|
||||
BOOST_VARIANT_APPLY_VISITOR_END() \
|
||||
} \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT( BOOST_PP_SUB(BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS, 2), BOOST_VARIANT_VISIT, const Visitor& visitor)
|
||||
BOOST_PP_REPEAT( BOOST_PP_SUB(BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS, 2), BOOST_VARIANT_VISIT, Visitor& visitor)
|
||||
|
||||
#undef BOOST_VARIANT_APPLY_VISITOR_BEG
|
||||
#undef BOOST_VARIANT_APPLY_VISITOR_END
|
||||
#undef BOOST_VARANT_VISITORS_VARIABLES_PRINTER
|
||||
#undef BOOST_VARIANT_VISIT
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_MULTIVISITORS_PREPROCESSOR_BASED_HPP
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
|
||||
#if !defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
///// header body
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/substitute.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
@@ -21,7 +16,7 @@
|
||||
#include <boost/mpl/aux_/config/ctps.hpp>
|
||||
|
||||
#include <boost/variant/detail/substitute_fwd.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp> // for BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
#include <boost/mpl/aux_/lambda_arity_param.hpp>
|
||||
#include <boost/mpl/aux_/preprocessor/params.hpp>
|
||||
#include <boost/mpl/aux_/preprocessor/repeat.hpp>
|
||||
@@ -35,8 +30,6 @@
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
|
||||
#if !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction substitute
|
||||
//
|
||||
@@ -126,7 +119,6 @@ struct substitute<
|
||||
// template expression (i.e., F<...>) specializations
|
||||
//
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
template <
|
||||
template <typename...> class F
|
||||
, typename... Ts
|
||||
@@ -170,110 +162,8 @@ public:
|
||||
A, Dest, Source
|
||||
>::type...);
|
||||
};
|
||||
#else
|
||||
|
||||
#define BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF_IMPL(N) \
|
||||
typedef typename substitute< \
|
||||
BOOST_PP_CAT(U,N), Dest, Source \
|
||||
>::type BOOST_PP_CAT(u,N); \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF(z, N, _) \
|
||||
BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF_IMPL( BOOST_PP_INC(N) ) \
|
||||
/**/
|
||||
|
||||
#define BOOST_PP_ITERATION_LIMITS (0,BOOST_MPL_LIMIT_METAFUNCTION_ARITY)
|
||||
#define BOOST_PP_FILENAME_1 <boost/variant/detail/substitute.hpp>
|
||||
#include BOOST_PP_ITERATE()
|
||||
|
||||
#undef BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF_IMPL
|
||||
#undef BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF
|
||||
|
||||
#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
#endif // !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_SUBSTITUTE_HPP
|
||||
|
||||
///// iteration, depth == 1
|
||||
|
||||
#elif BOOST_PP_ITERATION_DEPTH() == 1
|
||||
#define i BOOST_PP_FRAME_ITERATION(1)
|
||||
|
||||
#if i > 0
|
||||
|
||||
//
|
||||
// template specializations
|
||||
//
|
||||
template <
|
||||
template < BOOST_MPL_PP_PARAMS(i,typename P) > class T
|
||||
, BOOST_MPL_PP_PARAMS(i,typename U)
|
||||
, typename Dest
|
||||
, typename Source
|
||||
>
|
||||
struct substitute<
|
||||
T< BOOST_MPL_PP_PARAMS(i,U) >
|
||||
, Dest
|
||||
, Source
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<( i )>)
|
||||
>
|
||||
{
|
||||
private:
|
||||
BOOST_MPL_PP_REPEAT(i, BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF, _)
|
||||
|
||||
public:
|
||||
typedef T< BOOST_MPL_PP_PARAMS(i,u) > type;
|
||||
};
|
||||
|
||||
//
|
||||
// function specializations
|
||||
//
|
||||
template <
|
||||
typename R
|
||||
, BOOST_MPL_PP_PARAMS(i,typename U)
|
||||
, typename Dest
|
||||
, typename Source
|
||||
>
|
||||
struct substitute<
|
||||
R (*)( BOOST_MPL_PP_PARAMS(i,U) )
|
||||
, Dest
|
||||
, Source
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>)
|
||||
>
|
||||
{
|
||||
private:
|
||||
typedef typename substitute< R, Dest, Source >::type r;
|
||||
BOOST_MPL_PP_REPEAT(i, BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF, _)
|
||||
|
||||
public:
|
||||
typedef r (*type)( BOOST_MPL_PP_PARAMS(i,u) );
|
||||
};
|
||||
|
||||
#elif i == 0
|
||||
|
||||
//
|
||||
// zero-arg function specialization
|
||||
//
|
||||
template <
|
||||
typename R, typename Dest, typename Source
|
||||
>
|
||||
struct substitute<
|
||||
R (*)( void )
|
||||
, Dest
|
||||
, Source
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>)
|
||||
>
|
||||
{
|
||||
private:
|
||||
typedef typename substitute< R, Dest, Source >::type r;
|
||||
|
||||
public:
|
||||
typedef r (*type)( void );
|
||||
};
|
||||
|
||||
#endif // i
|
||||
|
||||
#undef i
|
||||
#endif // BOOST_PP_IS_ITERATING
|
||||
|
||||
@@ -18,25 +18,12 @@
|
||||
#include <boost/mpl/int_fwd.hpp>
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// BOOST_VARIANT_DETAIL_NO_SUBSTITUTE
|
||||
//
|
||||
// Defined if 'substitute' is not implementable on the current compiler.
|
||||
//
|
||||
|
||||
#include <boost/mpl/aux_/config/ctps.hpp>
|
||||
#include <boost/mpl/aux_/config/ttp.hpp>
|
||||
|
||||
#if defined(BOOST_NO_TEMPLATE_TEMPLATE_PARAMETERS) \
|
||||
&& !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
# define BOOST_VARIANT_DETAIL_NO_SUBSTITUTE
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
|
||||
#if !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// metafunction substitute
|
||||
//
|
||||
@@ -50,8 +37,6 @@ template <
|
||||
>
|
||||
struct substitute;
|
||||
|
||||
#endif // !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <boost/variant/detail/backup_holder.hpp>
|
||||
#include <boost/variant/detail/cast_storage.hpp>
|
||||
#include <boost/variant/detail/forced_return.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp> // for BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
@@ -47,14 +47,9 @@
|
||||
//
|
||||
#if !defined(BOOST_VARIANT_VISITATION_UNROLLING_LIMIT)
|
||||
|
||||
#ifndef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
# include <boost/mpl/limits/list.hpp>
|
||||
# define BOOST_VARIANT_VISITATION_UNROLLING_LIMIT \
|
||||
BOOST_MPL_LIMIT_LIST_SIZE
|
||||
#else
|
||||
# define BOOST_VARIANT_VISITATION_UNROLLING_LIMIT \
|
||||
BOOST_VARIANT_LIMIT_TYPES
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -17,15 +17,11 @@
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp> // for BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
# include <boost/variant/detail/multivisitors_cpp11_based.hpp>
|
||||
# if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
# include <boost/variant/detail/multivisitors_cpp14_based.hpp>
|
||||
# endif
|
||||
#else
|
||||
# include <boost/variant/detail/multivisitors_preprocessor_based.hpp>
|
||||
#include <boost/variant/detail/multivisitors_cpp11_based.hpp>
|
||||
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
# include <boost/variant/detail/multivisitors_cpp14_based.hpp>
|
||||
#endif
|
||||
|
||||
#endif // BOOST_VARIANT_MULTIVISITORS_HPP
|
||||
|
||||
@@ -45,8 +45,6 @@ namespace detail { namespace variant {
|
||||
// Handles embedded variant types when substituting for recursive_variant_.
|
||||
//
|
||||
|
||||
#if !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
template <
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename T)
|
||||
, typename RecursiveVariant
|
||||
@@ -115,9 +113,7 @@ struct substitute<
|
||||
, ::boost::recursive_variant_
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(Arity)
|
||||
>
|
||||
{
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
{
|
||||
typedef ::boost::variant<
|
||||
typename enable_recursive<
|
||||
T0
|
||||
@@ -130,41 +126,8 @@ struct substitute<
|
||||
, mpl::true_
|
||||
>::type...
|
||||
> type;
|
||||
|
||||
#else // defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
private: // helpers, for metafunction result (below)
|
||||
|
||||
#define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_TYPEDEFS(z,N,_) \
|
||||
typedef typename enable_recursive< \
|
||||
BOOST_PP_CAT(T,N) \
|
||||
, RecursiveVariant \
|
||||
, mpl::true_ \
|
||||
>::type BOOST_PP_CAT(wknd_T,N); \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_VARIANT_LIMIT_TYPES
|
||||
, BOOST_VARIANT_AUX_ENABLE_RECURSIVE_TYPEDEFS
|
||||
, _
|
||||
)
|
||||
|
||||
#undef BOOST_VARIANT_AUX_ENABLE_RECURSIVE_TYPEDEFS
|
||||
|
||||
public: // metafunction result
|
||||
|
||||
typedef ::boost::variant< BOOST_VARIANT_ENUM_PARAMS(wknd_T) > type;
|
||||
#endif // BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES workaround
|
||||
};
|
||||
|
||||
#else // defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
//
|
||||
// no specializations: embedded variants unsupported on these compilers!
|
||||
//
|
||||
|
||||
#endif // !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
}} // namespace detail::variant
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -221,7 +221,6 @@ public: // metafunction result
|
||||
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_CXX11_NOEXCEPT
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction is_variant_move_noexcept_constructible
|
||||
//
|
||||
@@ -255,7 +254,6 @@ struct is_variant_move_noexcept_assignable {
|
||||
iterator_t, end_t
|
||||
>::type type;
|
||||
};
|
||||
#endif // BOOST_NO_CXX11_NOEXCEPT
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction is_variant_constructible_from
|
||||
@@ -308,8 +306,6 @@ struct is_variant_constructible_from< boost::variant<BOOST_VARIANT_ENUM_PARAMS(T
|
||||
is_variant_constructible_from<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Types >
|
||||
{};
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
template <BOOST_VARIANT_ENUM_PARAMS(typename T), class Types>
|
||||
struct is_variant_constructible_from< boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>&& , Types >:
|
||||
is_variant_constructible_from<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Types >
|
||||
@@ -320,8 +316,6 @@ struct is_variant_constructible_from< boost::variant<BOOST_VARIANT_ENUM_PARAMS(T
|
||||
is_variant_constructible_from<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Types >
|
||||
{};
|
||||
|
||||
#endif // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCE
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction make_storage
|
||||
@@ -466,7 +460,6 @@ public: // internal visitor interface
|
||||
//
|
||||
// Internal visitor that moves the value it visits into the given buffer.
|
||||
//
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
class move_into
|
||||
: public static_visitor<>
|
||||
{
|
||||
@@ -495,7 +488,6 @@ public: // internal visitor interface
|
||||
new(storage_) T(::boost::detail::variant::move(operand));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) class assign_storage
|
||||
@@ -1012,13 +1004,11 @@ public: // structors
|
||||
|
||||
public: // internal visitor interfaces
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
//using workaround with is_same<T, T> to prenvent compilation error, because we need to use T in enable_if to make SFINAE work
|
||||
template <typename T>
|
||||
typename enable_if_c<MoveSemantics && is_same<T, T>::value, result_type>::type internal_visit(T&& operand, int)
|
||||
{
|
||||
return visitor_(::boost::move(operand));
|
||||
return visitor_(std::move(operand));
|
||||
}
|
||||
|
||||
//using workaround with is_same<T, T> to prenvent compilation error, because we need to use T in enable_if to make SFINAE work
|
||||
@@ -1028,24 +1018,6 @@ public: // internal visitor interfaces
|
||||
return visitor_(operand);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template <typename T>
|
||||
result_type internal_visit(T& operand, int)
|
||||
{
|
||||
return visitor_(operand);
|
||||
}
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x0564))
|
||||
template <typename T>
|
||||
result_type internal_visit(const T& operand, int)
|
||||
{
|
||||
return visitor_(operand);
|
||||
}
|
||||
# endif //BORLAND
|
||||
|
||||
#endif //RVALUE REFERENCES
|
||||
|
||||
public: // internal visitor interfaces, cont.
|
||||
|
||||
template <typename T>
|
||||
@@ -1270,7 +1242,6 @@ private: // helpers, for representation (below)
|
||||
internal_types, never_uses_backup_flag
|
||||
>::type storage_t;
|
||||
|
||||
#ifndef BOOST_NO_CXX11_NOEXCEPT
|
||||
typedef typename detail::variant::is_variant_move_noexcept_constructible<
|
||||
internal_types
|
||||
> variant_move_noexcept_constructible;
|
||||
@@ -1279,8 +1250,6 @@ private: // helpers, for representation (below)
|
||||
internal_types
|
||||
> variant_move_noexcept_assignable;
|
||||
|
||||
#endif
|
||||
|
||||
private: // helpers, for representation (below)
|
||||
|
||||
// which_ on:
|
||||
@@ -1471,7 +1440,6 @@ private: // helpers, for structors, cont. (below)
|
||||
|
||||
friend class convert_copy_into;
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
class convert_move_into
|
||||
: public static_visitor<int>
|
||||
{
|
||||
@@ -1537,7 +1505,6 @@ private: // helpers, for structors, cont. (below)
|
||||
};
|
||||
|
||||
friend class convert_move_into;
|
||||
#endif
|
||||
|
||||
private: // helpers, for structors, below
|
||||
|
||||
@@ -1561,7 +1528,6 @@ private: // helpers, for structors, below
|
||||
);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <typename T>
|
||||
typename boost::enable_if<boost::is_rvalue_reference<T&&> >::type convert_construct(
|
||||
T&& operand
|
||||
@@ -1581,7 +1547,6 @@ private: // helpers, for structors, below
|
||||
)
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename Variant>
|
||||
void convert_construct(
|
||||
@@ -1596,7 +1561,6 @@ private: // helpers, for structors, below
|
||||
);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <typename Variant>
|
||||
typename boost::enable_if<boost::is_rvalue_reference<Variant&&> >::type convert_construct(
|
||||
Variant&& operand
|
||||
@@ -1609,7 +1573,6 @@ private: // helpers, for structors, below
|
||||
operand.internal_apply_visitor(visitor)
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename Variant>
|
||||
void convert_construct_variant(Variant& operand)
|
||||
@@ -1638,7 +1601,6 @@ private: // helpers, for structors, below
|
||||
);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <typename Variant>
|
||||
typename boost::enable_if<boost::is_rvalue_reference<Variant&&> >::type convert_construct_variant(Variant&& operand)
|
||||
{
|
||||
@@ -1665,7 +1627,6 @@ private: // helpers, for structors, below
|
||||
, is_foreign_variant()
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <BOOST_VARIANT_ENUM_PARAMS(typename U)>
|
||||
typename boost::enable_if<mpl::or_<
|
||||
@@ -1691,7 +1652,6 @@ private: // helpers, for structors, below
|
||||
convert_construct_variant(operand);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <BOOST_VARIANT_ENUM_PARAMS(typename U)>
|
||||
typename boost::enable_if<mpl::or_<
|
||||
boost::is_same<boost::variant<BOOST_VARIANT_ENUM_PARAMS(U)>, variant>,
|
||||
@@ -1703,7 +1663,6 @@ private: // helpers, for structors, below
|
||||
{
|
||||
convert_construct_variant( detail::variant::move(operand) );
|
||||
}
|
||||
#endif
|
||||
|
||||
public: // structors, cont.
|
||||
|
||||
@@ -1736,7 +1695,6 @@ public: // structors, cont.
|
||||
convert_construct(operand, 1L);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <class T>
|
||||
variant(T&& operand,
|
||||
typename boost::enable_if<mpl::or_<
|
||||
@@ -1751,7 +1709,6 @@ public: // structors, cont.
|
||||
{
|
||||
convert_construct( detail::variant::move(operand), 1L);
|
||||
}
|
||||
#endif
|
||||
|
||||
public: // structors, cont.
|
||||
|
||||
@@ -1766,7 +1723,6 @@ public: // structors, cont.
|
||||
indicate_which(operand.which());
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
variant(variant&& operand) BOOST_NOEXCEPT_IF(variant_move_noexcept_constructible::type::value)
|
||||
{
|
||||
// Move the value of operand into *this...
|
||||
@@ -1776,14 +1732,11 @@ public: // structors, cont.
|
||||
// ...and activate the *this's primary storage on success:
|
||||
indicate_which(operand.which());
|
||||
}
|
||||
#endif
|
||||
|
||||
private: // helpers, for modifiers (below)
|
||||
|
||||
# if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
|
||||
template <typename Variant>
|
||||
friend class detail::variant::backup_assigner;
|
||||
# endif
|
||||
|
||||
// class assigner
|
||||
//
|
||||
@@ -1933,7 +1886,6 @@ private: // helpers, for modifiers (below)
|
||||
|
||||
friend class assigner;
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
// class move_assigner
|
||||
//
|
||||
// Internal visitor that "move assigns" the visited value to the given variant
|
||||
@@ -2051,7 +2003,6 @@ private: // helpers, for modifiers (below)
|
||||
};
|
||||
|
||||
friend class move_assigner;
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
void variant_assign(const variant& rhs)
|
||||
{
|
||||
@@ -2070,7 +2021,6 @@ private: // helpers, for modifiers (below)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
void variant_assign(variant&& rhs)
|
||||
{
|
||||
// If the contained types are EXACTLY the same...
|
||||
@@ -2087,7 +2037,6 @@ private: // helpers, for modifiers (below)
|
||||
rhs.internal_apply_visitor(visitor);
|
||||
}
|
||||
}
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
private: // helpers, for modifiers (below)
|
||||
|
||||
@@ -2109,7 +2058,6 @@ private: // helpers, for modifiers (below)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <typename T>
|
||||
void move_assign(T&& rhs)
|
||||
{
|
||||
@@ -2127,12 +2075,10 @@ private: // helpers, for modifiers (below)
|
||||
variant_assign( detail::variant::move(temp) );
|
||||
}
|
||||
}
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
public: // modifiers
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
(!BOOST_WORKAROUND(BOOST_CLANG_VERSION, BOOST_TESTED_AT(150000)) || BOOST_CXX_VERSION <= 202002L)
|
||||
#if !BOOST_WORKAROUND(BOOST_CLANG_VERSION, BOOST_TESTED_AT(150000)) || BOOST_CXX_VERSION <= 202002L
|
||||
template <class T>
|
||||
typename boost::enable_if<
|
||||
boost::mpl::and_<
|
||||
@@ -2146,7 +2092,7 @@ public: // modifiers
|
||||
move_assign( detail::variant::move(rhs) );
|
||||
return *this;
|
||||
}
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
typename boost::enable_if<
|
||||
@@ -2168,7 +2114,6 @@ public: // modifiers
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
variant& operator=(variant&& rhs)
|
||||
#if !defined(__GNUC__) || (__GNUC__ != 4) || (__GNUC_MINOR__ > 6) || defined(__clang__)
|
||||
BOOST_NOEXCEPT_IF(variant_move_noexcept_constructible::type::value && variant_move_noexcept_assignable::type::value)
|
||||
@@ -2177,7 +2122,6 @@ public: // modifiers
|
||||
variant_assign( detail::variant::move(rhs) );
|
||||
return *this;
|
||||
}
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
void swap(variant& rhs)
|
||||
{
|
||||
@@ -2363,8 +2307,6 @@ public:
|
||||
|
||||
public: // visitation support
|
||||
|
||||
#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
|
||||
|
||||
template <typename Visitor>
|
||||
typename Visitor::result_type
|
||||
apply_visitor(Visitor& visitor) &&
|
||||
@@ -2381,14 +2323,9 @@ public: // visitation support
|
||||
return this->internal_apply_visitor(invoker);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template <typename Visitor>
|
||||
typename Visitor::result_type
|
||||
apply_visitor(Visitor& visitor)
|
||||
#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
|
||||
&
|
||||
#endif
|
||||
apply_visitor(Visitor& visitor) &
|
||||
{
|
||||
detail::variant::invoke_visitor<Visitor, false> invoker(visitor);
|
||||
return this->internal_apply_visitor(invoker);
|
||||
@@ -2396,10 +2333,7 @@ public: // visitation support
|
||||
|
||||
template <typename Visitor>
|
||||
typename Visitor::result_type
|
||||
apply_visitor(Visitor& visitor) const
|
||||
#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
|
||||
&
|
||||
#endif
|
||||
apply_visitor(Visitor& visitor) const &
|
||||
{
|
||||
detail::variant::invoke_visitor<Visitor, false> invoker(visitor);
|
||||
return this->internal_apply_visitor(invoker);
|
||||
|
||||
@@ -45,37 +45,6 @@
|
||||
|
||||
#include <boost/variant/detail/substitute_fwd.hpp>
|
||||
|
||||
#if defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE) \
|
||||
&& !defined(BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT)
|
||||
# define BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT
|
||||
#endif
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
//
|
||||
|
||||
/*
|
||||
GCC before 4.0 had no variadic tempaltes;
|
||||
GCC 4.6 has incomplete implementation of variadic templates.
|
||||
|
||||
MSVC2015 Update 1 has variadic templates, but they have issues.
|
||||
|
||||
NOTE: Clang compiler defines __GNUC__
|
||||
*/
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) \
|
||||
|| (!defined(__clang__) && defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7)) \
|
||||
|| (defined(_MSC_VER) && (_MSC_VER <= 1900)) \
|
||||
|| defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE) \
|
||||
|| defined (BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT)
|
||||
|
||||
#ifndef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
# define BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
#include <boost/preprocessor/seq/size.hpp>
|
||||
|
||||
#define BOOST_VARIANT_CLASS_OR_TYPENAME_TO_SEQ_class class)(
|
||||
@@ -108,9 +77,6 @@
|
||||
// Rationale: Cleaner, simpler code for clients of variant library. Minimal
|
||||
// code modifications to move from C++03 to C++11.
|
||||
//
|
||||
// With BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES defined
|
||||
// will be used BOOST_VARIANT_ENUM_PARAMS and BOOST_VARIANT_ENUM_SHIFTED_PARAMS from below `#else`
|
||||
//
|
||||
|
||||
#define BOOST_VARIANT_ENUM_PARAMS(x) \
|
||||
x ## 0, \
|
||||
@@ -121,49 +87,6 @@
|
||||
BOOST_VARIANT_MAKE_VARIADIC( (BOOST_VARIANT_CLASS_OR_TYPENAME_TO_SEQ_ ## x), x) \
|
||||
/**/
|
||||
|
||||
#else // defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_LIMIT_TYPES
|
||||
//
|
||||
// Implementation-defined preprocessor symbol describing the actual
|
||||
// length of variant's pseudo-variadic template parameter list.
|
||||
//
|
||||
#include <boost/mpl/limits/list.hpp>
|
||||
#define BOOST_VARIANT_LIMIT_TYPES \
|
||||
BOOST_MPL_LIMIT_LIST_SIZE
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_RECURSIVE_VARIANT_MAX_ARITY
|
||||
//
|
||||
// Exposes maximum allowed arity of class templates with recursive_variant
|
||||
// arguments. That is,
|
||||
// make_recursive_variant< ..., T<[1], recursive_variant_, ... [N]> >.
|
||||
//
|
||||
#include <boost/mpl/limits/arity.hpp>
|
||||
#define BOOST_VARIANT_RECURSIVE_VARIANT_MAX_ARITY \
|
||||
BOOST_MPL_LIMIT_METAFUNCTION_ARITY
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_ENUM_PARAMS
|
||||
//
|
||||
// Convenience macro for enumeration of BOOST_VARIANT_LIMIT_TYPES params.
|
||||
//
|
||||
// Rationale: Cleaner, simpler code for clients of variant library.
|
||||
//
|
||||
#define BOOST_VARIANT_ENUM_PARAMS( param ) \
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_VARIANT_LIMIT_TYPES, param)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_ENUM_SHIFTED_PARAMS
|
||||
//
|
||||
// Convenience macro for enumeration of BOOST_VARIANT_LIMIT_TYPES-1 params.
|
||||
//
|
||||
#define BOOST_VARIANT_ENUM_SHIFTED_PARAMS( param ) \
|
||||
BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_VARIANT_LIMIT_TYPES, param)
|
||||
|
||||
#endif // BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES workaround
|
||||
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -231,39 +154,7 @@ BOOST_PP_REPEAT(
|
||||
|
||||
}} // namespace detail::variant
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
# define BOOST_VARIANT_AUX_DECLARE_PARAMS BOOST_VARIANT_ENUM_PARAMS(typename T)
|
||||
#else // defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) macro BOOST_VARIANT_AUX_DECLARE_PARAM
|
||||
//
|
||||
// Template parameter list for variant and recursive_variant declarations.
|
||||
//
|
||||
|
||||
#if !defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
|
||||
# define BOOST_VARIANT_AUX_DECLARE_PARAMS_IMPL(z, N, T) \
|
||||
typename BOOST_PP_CAT(T,N) = detail::variant::void_ \
|
||||
/**/
|
||||
|
||||
#else // defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
|
||||
# define BOOST_VARIANT_AUX_DECLARE_PARAMS_IMPL(z, N, T) \
|
||||
typename BOOST_PP_CAT(T,N) = BOOST_PP_CAT(detail::variant::void,N) \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE workaround
|
||||
|
||||
#define BOOST_VARIANT_AUX_DECLARE_PARAMS \
|
||||
BOOST_PP_ENUM( \
|
||||
BOOST_VARIANT_LIMIT_TYPES \
|
||||
, BOOST_VARIANT_AUX_DECLARE_PARAMS_IMPL \
|
||||
, T \
|
||||
) \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES workaround
|
||||
#define BOOST_VARIANT_AUX_DECLARE_PARAMS BOOST_VARIANT_ENUM_PARAMS(typename T)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// class template variant (concept inspired by Andrei Alexandrescu)
|
||||
|
||||
+1
-1
@@ -14,5 +14,5 @@
|
||||
"Antony Polukhin <antoshkka -at- gmail.com>",
|
||||
"Eric Friedman <ericbrandon -at- gmail.com>"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
"cxxstd": "11"
|
||||
}
|
||||
|
||||
+3
-2
@@ -9,13 +9,14 @@
|
||||
#
|
||||
|
||||
import testing ;
|
||||
import ../../config/checks/config : requires ;
|
||||
|
||||
local below_cpp11 = 98 03 ;
|
||||
local below_cpp14 = 98 03 0x 11 ;
|
||||
local since_cpp20 = 2a 20 latest ;
|
||||
|
||||
project
|
||||
: requirements
|
||||
[ requires cxx11_rvalue_references ]
|
||||
<toolset>msvc:<asynch-exceptions>on
|
||||
;
|
||||
test-suite variant
|
||||
@@ -38,7 +39,7 @@ test-suite variant
|
||||
[ run variant_get_test.cpp ]
|
||||
[ compile-fail variant_rvalue_get_with_ampersand_test.cpp ]
|
||||
[ compile-fail no_rvalue_to_nonconst_visitation.cpp ]
|
||||
[ compile fusion_interop.cpp : "<cxxstd>$(below_cpp11)"\:<build>no ]
|
||||
[ compile fusion_interop.cpp ]
|
||||
[ run variant_polymorphic_get_test.cpp ]
|
||||
[ run variant_multivisit_test.cpp ]
|
||||
[ run hash_variant_test.cpp ]
|
||||
|
||||
@@ -32,9 +32,6 @@ skip_tags: true
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
|
||||
ADDRMD: 32
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1,clang-win
|
||||
CXXSTD: 14,17
|
||||
|
||||
+9
-19
@@ -188,12 +188,6 @@ struct lex_streamer2 {
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
# define BOOST_TEST_IF_HAS_VARIADIC(x) BOOST_TEST(x)
|
||||
#else
|
||||
# define BOOST_TEST_IF_HAS_VARIADIC(x) /**/
|
||||
#endif
|
||||
|
||||
void run()
|
||||
{
|
||||
typedef boost::variant<int, std::string, double> variant_type;
|
||||
@@ -201,9 +195,9 @@ void run()
|
||||
lex_streamer lex_streamer_visitor;
|
||||
|
||||
BOOST_TEST(boost::apply_visitor(lex_streamer(), v1) == "1");
|
||||
BOOST_TEST_IF_HAS_VARIADIC(boost::apply_visitor(lex_streamer_visitor)(v1) == "1");
|
||||
BOOST_TEST(boost::apply_visitor(lex_streamer_visitor)(v1) == "1");
|
||||
BOOST_TEST(boost::apply_visitor(lex_streamer(), v2) == "10");
|
||||
BOOST_TEST_IF_HAS_VARIADIC(boost::apply_visitor(lex_streamer_visitor)(v2) == "10");
|
||||
BOOST_TEST(boost::apply_visitor(lex_streamer_visitor)(v2) == "10");
|
||||
|
||||
#ifndef BOOST_NO_CXX14_GENERIC_LAMBDAS
|
||||
BOOST_TEST(boost::apply_visitor([](auto v) { return boost::lexical_cast<std::string>(v); }, v1) == "1");
|
||||
@@ -220,16 +214,16 @@ void run()
|
||||
lex_streamer2 visitor_ref;
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v1) == "1");
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v2) == "10");
|
||||
#ifndef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
|
||||
std::string& ref_to_string = boost::apply_visitor(visitor_ref, v1);
|
||||
BOOST_TEST(ref_to_string == "1");
|
||||
#endif
|
||||
|
||||
lex_streamer_void lex_streamer_void_visitor;
|
||||
boost::apply_visitor(lex_streamer_void(), v1);
|
||||
boost::apply_visitor(lex_streamer_void(), v2);
|
||||
#ifndef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
|
||||
boost::apply_visitor(lex_streamer_void_visitor)(v2);
|
||||
#endif
|
||||
|
||||
|
||||
boost::ignore_unused(lex_streamer_visitor, visitor_ref, lex_streamer_void_visitor);
|
||||
}
|
||||
@@ -258,7 +252,7 @@ void run2()
|
||||
|
||||
BOOST_TEST(boost::apply_visitor(lex_combine(), v1, v2) == "1+10");
|
||||
BOOST_TEST(boost::apply_visitor(lex_combine(), v2, v1) == "10+1");
|
||||
BOOST_TEST_IF_HAS_VARIADIC(boost::apply_visitor(lex_combine_visitor)(v2, v1) == "10+1");
|
||||
BOOST_TEST(boost::apply_visitor(lex_combine_visitor)(v2, v1) == "10+1");
|
||||
|
||||
|
||||
#ifndef BOOST_NO_CXX14_GENERIC_LAMBDAS
|
||||
@@ -291,10 +285,9 @@ void run2()
|
||||
lex_streamer2 visitor_ref;
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v1, v2) == "1+10");
|
||||
BOOST_TEST(boost::apply_visitor(visitor_ref, v2, v1) == "10+1");
|
||||
#ifndef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
|
||||
std::string& ref_to_string = boost::apply_visitor(visitor_ref)(v1, v2);
|
||||
BOOST_TEST(ref_to_string == "1+10");
|
||||
#endif
|
||||
|
||||
boost::apply_visitor(lex_streamer_void(), v1, v2);
|
||||
boost::apply_visitor(lex_streamer_void(), v2, v1);
|
||||
@@ -302,11 +295,8 @@ void run2()
|
||||
boost::ignore_unused(lex_combine_visitor, visitor_ref);
|
||||
}
|
||||
|
||||
#undef BOOST_TEST_IF_HAS_VARIADIC
|
||||
|
||||
void run3()
|
||||
{
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
typedef boost::variant<int, std::string, double> variant_type;
|
||||
variant_type v1(1), v2("10"), v3(100);
|
||||
lex_combine lex_combine_visitor;
|
||||
@@ -363,7 +353,7 @@ void run3()
|
||||
boost::apply_visitor(lex_streamer_void(), v1, v2, v1);
|
||||
boost::apply_visitor(lex_streamer_void(), v2, v1, v1);
|
||||
boost::apply_visitor(lex_streamer_void_visitor)(v2, v1, v1);
|
||||
#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -29,13 +29,11 @@ struct construction_logger
|
||||
std::cout << val_ << " copy constructed\n";
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
construction_logger(construction_logger&& cl) :
|
||||
val_(cl.val_)
|
||||
{
|
||||
std::cout << val_ << " move constructed\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
friend std::ostream& operator << (std::ostream& os, const construction_logger& cl)
|
||||
{
|
||||
@@ -71,7 +69,6 @@ struct lex_streamer_explicit : boost::static_visitor<std::string>
|
||||
|
||||
struct lvalue_rvalue_detector : boost::static_visitor<std::string>
|
||||
{
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <class T>
|
||||
std::string operator()(T&&) const
|
||||
{
|
||||
@@ -96,31 +93,6 @@ struct lvalue_rvalue_detector : boost::static_visitor<std::string>
|
||||
{
|
||||
return operator()(std::forward<T>(t), std::forward<V>(v), std::forward<P>(p)) + ", " + operator()(std::forward<S>(s));
|
||||
}
|
||||
#else
|
||||
template <class T>
|
||||
std::string operator()(T&) const
|
||||
{
|
||||
return "lvalue reference";
|
||||
}
|
||||
|
||||
template <class T, class V>
|
||||
std::string operator()(T&, V&) const
|
||||
{
|
||||
return "lvalue reference, lvalue reference";
|
||||
}
|
||||
|
||||
template <class T, class V, class P>
|
||||
std::string operator()(T&, V&, P&) const
|
||||
{
|
||||
return "lvalue reference, lvalue reference, lvalue reference";
|
||||
}
|
||||
|
||||
template <class T, class V, class P, class S>
|
||||
std::string operator()(T&, V&, P&, S&) const
|
||||
{
|
||||
return "lvalue reference, lvalue reference, lvalue reference, lvalue reference";
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef boost::variant<construction_logger, std::string> variant_type;
|
||||
@@ -147,8 +119,6 @@ void test_const_ref_parameter4(const variant_type& test_var, const variant_type&
|
||||
== "lvalue reference, lvalue reference, lvalue reference, lvalue reference");
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
|
||||
|
||||
void test_rvalue_parameter(variant_type&& test_var)
|
||||
{
|
||||
std::cout << "Testing rvalue visitable\n";
|
||||
@@ -166,22 +136,13 @@ void test_rvalue_parameter2(variant_type&& test_var, variant_type&& test_var2)
|
||||
|
||||
void test_rvalue_parameter4(variant_type&& test_var, variant_type&& test_var2, variant_type&& test_var3, variant_type&& test_var4)
|
||||
{
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
std::cout << "Testing rvalue visitable with multivisitor\n";
|
||||
|
||||
auto result = boost::apply_visitor(lvalue_rvalue_detector(), std::move(test_var), std::move(test_var2), std::move(test_var3), std::move(test_var4));
|
||||
std::cout << "result: " << result << std::endl;
|
||||
BOOST_TEST(result == "rvalue reference, rvalue reference, rvalue reference, rvalue reference");
|
||||
#else
|
||||
(void)test_var;
|
||||
(void)test_var2;
|
||||
(void)test_var3;
|
||||
(void)test_var4;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX14_DECLTYPE_AUTO
|
||||
|
||||
#define FORWARD(x) std::forward<decltype(x)>(x)
|
||||
@@ -210,18 +171,12 @@ void test_cpp14_visitor(const variant_type& test_var, const variant_type& test_v
|
||||
|
||||
void test_cpp14_visitor(const variant_type& test_var, const variant_type& test_var2, const variant_type& test_var3)
|
||||
{
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
std::cout << "Testing const lvalue visitable for c++14\n";
|
||||
|
||||
auto result = boost::apply_visitor([](auto&& v, auto&& t, auto&& p) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t), FORWARD(p)); },
|
||||
test_var, test_var2, test_var3);
|
||||
std::cout << "result: " << result << std::endl;
|
||||
BOOST_TEST(result == "lvalue reference, lvalue reference, lvalue reference");
|
||||
#else
|
||||
(void)test_var;
|
||||
(void)test_var2;
|
||||
(void)test_var3;
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_cpp14_visitor(variant_type& test_var)
|
||||
@@ -248,18 +203,12 @@ void test_cpp14_visitor(variant_type& test_var, variant_type& test_var2)
|
||||
|
||||
void test_cpp14_visitor(variant_type& test_var, variant_type& test_var2, variant_type& test_var3)
|
||||
{
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
std::cout << "Testing lvalue visitable for c++14\n";
|
||||
|
||||
auto result = boost::apply_visitor([](auto& v, auto& t, auto& p) { return lvalue_rvalue_detector()(v, t, p); },
|
||||
test_var, test_var2, test_var3);
|
||||
std::cout << "result: " << result << std::endl;
|
||||
BOOST_TEST(result == "lvalue reference, lvalue reference, lvalue reference");
|
||||
#else
|
||||
(void)test_var;
|
||||
(void)test_var2;
|
||||
(void)test_var3;
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_cpp14_visitor(variant_type&& test_var)
|
||||
@@ -279,21 +228,15 @@ void test_cpp14_visitor(variant_type&& test_var, variant_type&& test_var2)
|
||||
|
||||
void test_cpp14_visitor(variant_type&& test_var, variant_type&& test_var2, variant_type&& test_var3)
|
||||
{
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
std::cout << "Testing rvalue visitable for c++14\n";
|
||||
|
||||
auto result = boost::apply_visitor([](auto&& v, auto&& t, auto&& p) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t), FORWARD(p)); },
|
||||
std::move(test_var), std::move(test_var2), std::move(test_var3));
|
||||
std::cout << "result: " << result << std::endl;
|
||||
BOOST_TEST(result == "rvalue reference, rvalue reference, rvalue reference");
|
||||
#else
|
||||
(void)test_var;
|
||||
(void)test_var2;
|
||||
(void)test_var3;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // #ifndef BOOST_NO_CXX14_DECLTYPE_AUTO
|
||||
|
||||
void run_const_lvalue_ref_tests()
|
||||
{
|
||||
@@ -305,53 +248,29 @@ void run_const_lvalue_ref_tests()
|
||||
|
||||
void run_rvalue_ref_tests()
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
|
||||
variant_type v1(10), v2(20), v3(30);
|
||||
test_rvalue_parameter(boost::move(v1));
|
||||
test_rvalue_parameter2(boost::move(v2), boost::move(v3));
|
||||
test_rvalue_parameter(std::move(v1));
|
||||
test_rvalue_parameter2(std::move(v2), std::move(v3));
|
||||
|
||||
variant_type vv1(100), vv2(200), vv3(300), vv4(400);
|
||||
test_rvalue_parameter4(boost::move(vv1), boost::move(vv2), boost::move(vv3), boost::move(vv4));
|
||||
#endif
|
||||
test_rvalue_parameter4(std::move(vv1), std::move(vv2), std::move(vv3), std::move(vv4));
|
||||
}
|
||||
|
||||
void run_mixed_tests()
|
||||
{
|
||||
variant_type v1(1), v2(2);
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
|
||||
std::cout << "Testing lvalue + rvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), v1, variant_type(10)) == "lvalue reference, rvalue reference");
|
||||
|
||||
std::cout << "Testing rvalue + lvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), variant_type(10), v1) == "rvalue reference, lvalue reference");
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
std::cout << "Testing rvalue + lvalue + rvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), variant_type(10), v1, variant_type(20)) == "rvalue reference, lvalue reference, rvalue reference");
|
||||
|
||||
std::cout << "Testing lvalue + rvalue + lvalue + rvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), v1, variant_type(10), v2, variant_type(20)) == "lvalue reference, rvalue reference, lvalue reference, rvalue reference");
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_NO_CXX11_REF_QUALIFIERS
|
||||
|
||||
#else // #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
std::cout << "Testing lvalue + rvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), v1, v1) == "lvalue reference, lvalue reference");
|
||||
|
||||
std::cout << "Testing rvalue + lvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), static_cast<const variant_type&>(variant_type(10)), v1) == "lvalue reference, lvalue reference");
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
std::cout << "Testing rvalue + lvalue + rvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), static_cast<const variant_type&>(variant_type(10)), v1, static_cast<const variant_type&>(variant_type(20))) == "lvalue reference, lvalue reference, lvalue reference");
|
||||
|
||||
std::cout << "Testing lvalue + rvalue + lvalue + rvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor(lvalue_rvalue_detector(), v1, static_cast<const variant_type&>(variant_type(10)), v2, static_cast<const variant_type&>(variant_type(20))) == "lvalue reference, lvalue reference, lvalue reference, lvalue reference");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void run_cpp14_mixed_tests()
|
||||
@@ -367,7 +286,6 @@ void run_cpp14_mixed_tests()
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v, auto&& t) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t)); },
|
||||
variant_type(10), v1) == "rvalue reference, lvalue reference");
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
std::cout << "Testing rvalue + lvalue + lvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v, auto&& t, auto&& p) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t), FORWARD(p)); },
|
||||
variant_type(10), v1, v2) == "rvalue reference, lvalue reference, lvalue reference");
|
||||
@@ -375,8 +293,7 @@ void run_cpp14_mixed_tests()
|
||||
std::cout << "Testing lvalue + rvalue + lvalue visitable\n";
|
||||
BOOST_TEST(boost::apply_visitor([](auto&& v, auto&& t, auto&& p) { return lvalue_rvalue_detector()(FORWARD(v), FORWARD(t), FORWARD(p)); },
|
||||
v1, variant_type(10), v2) == "lvalue reference, rvalue reference, lvalue reference");
|
||||
#endif
|
||||
#endif
|
||||
#endif // #ifndef BOOST_NO_CXX14_DECLTYPE_AUTO
|
||||
}
|
||||
|
||||
void run_cpp14_tests()
|
||||
@@ -395,11 +312,11 @@ void run_cpp14_tests()
|
||||
test_cpp14_visitor(v2, v3);
|
||||
test_cpp14_visitor(v1, v2, v3);
|
||||
|
||||
test_cpp14_visitor(boost::move(v1));
|
||||
test_cpp14_visitor(boost::move(v2), boost::move(v3));
|
||||
test_cpp14_visitor(std::move(v1));
|
||||
test_cpp14_visitor(std::move(v2), std::move(v3));
|
||||
|
||||
variant_type vv1(100), vv2(200), vv3(300);
|
||||
test_cpp14_visitor(boost::move(vv1), boost::move(vv2), boost::move(vv3));
|
||||
test_cpp14_visitor(std::move(vv1), std::move(vv2), std::move(vv3));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2021 Antony Polukhin
|
||||
// Copyright (c) 2021-2023 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
#include <boost/fusion/include/vector.hpp>
|
||||
|
||||
struct emptyList {};
|
||||
@@ -29,5 +27,3 @@ IntList cons( int head, IntList tail )
|
||||
{
|
||||
return IntList( boost::fusion::vector<int, IntList>( head, tail ) );
|
||||
}
|
||||
|
||||
#endif // #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
@@ -29,9 +29,7 @@
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
#include <tuple>
|
||||
#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
|
||||
struct Nil {};
|
||||
|
||||
@@ -61,7 +59,6 @@ struct printer
|
||||
return ost.str();
|
||||
}
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
template <int...> struct indices {};
|
||||
template <typename... Ts, int... Is>
|
||||
std::string operator()(const std::tuple<Ts...>& tup, indices<Is...>) const
|
||||
@@ -83,7 +80,6 @@ struct printer
|
||||
{
|
||||
return printer()(tup, make_indices<sizeof...(Ts)>());
|
||||
}
|
||||
#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
|
||||
template <typename T>
|
||||
std::string operator()(const T& operand) const
|
||||
@@ -215,7 +211,6 @@ void test_recursive_variant()
|
||||
>::type var6_t;
|
||||
var6_t var6;
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
typedef boost::make_recursive_variant<
|
||||
int,
|
||||
std::tuple<int, boost::recursive_variant_>
|
||||
@@ -228,7 +223,6 @@ void test_recursive_variant()
|
||||
|
||||
std::cout << "result7: " << result7 << '\n';
|
||||
BOOST_TEST(result7 == "( 2 ( 1 0 ) ) ");
|
||||
#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
}
|
||||
|
||||
void test_recursive_variant_over()
|
||||
|
||||
+11
-69
@@ -39,11 +39,11 @@ public:
|
||||
static unsigned int copy_count;
|
||||
|
||||
move_copy_conting_class(){}
|
||||
move_copy_conting_class(BOOST_RV_REF(move_copy_conting_class) ) {
|
||||
move_copy_conting_class(move_copy_conting_class&& ) {
|
||||
++ moves_count;
|
||||
}
|
||||
|
||||
move_copy_conting_class& operator=(BOOST_RV_REF(move_copy_conting_class) ) {
|
||||
move_copy_conting_class& operator=(move_copy_conting_class&& ) {
|
||||
++ moves_count;
|
||||
return *this;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
move_copy_conting_class(const move_copy_conting_class&) {
|
||||
++ copy_count;
|
||||
}
|
||||
move_copy_conting_class& operator=(BOOST_COPY_ASSIGN_REF(move_copy_conting_class) ) {
|
||||
move_copy_conting_class& operator=(const move_copy_conting_class& ) {
|
||||
++ copy_count;
|
||||
return *this;
|
||||
}
|
||||
@@ -60,53 +60,6 @@ public:
|
||||
unsigned int move_copy_conting_class::moves_count = 0;
|
||||
unsigned int move_copy_conting_class::copy_count = 0;
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
void run()
|
||||
{
|
||||
// Making sure that internals of Boost.Move do not interfere with
|
||||
// internals of Boost.Variant and in case of C++03 or C++98 compilation
|
||||
// is still possible.
|
||||
typedef boost::variant<int, move_copy_conting_class> variant_I_type;
|
||||
variant_I_type v1, v2;
|
||||
v1 = move_copy_conting_class();
|
||||
v2 = v1;
|
||||
v2 = boost::move(v1);
|
||||
v1.swap(v2);
|
||||
|
||||
move_copy_conting_class val;
|
||||
v2 = boost::move(val);
|
||||
v2 = 10;
|
||||
|
||||
variant_I_type v3(boost::move(val));
|
||||
variant_I_type v4(boost::move(v1));
|
||||
}
|
||||
|
||||
void run1()
|
||||
{
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
void run_move_only()
|
||||
{
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
void run_moves_are_noexcept()
|
||||
{
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
|
||||
void run_const_rvalues()
|
||||
{
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
void run()
|
||||
{
|
||||
typedef boost::variant<int, move_copy_conting_class> variant_I_type;
|
||||
@@ -131,7 +84,7 @@ void run()
|
||||
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v2 = boost::move(v1);
|
||||
v2 = std::move(v1);
|
||||
// Assuring that `move_copy_conting_class` in v1 was moved at least once and was not copied
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_TEST(move_copy_conting_class::copy_count == 0);
|
||||
@@ -139,7 +92,7 @@ void run()
|
||||
v1 = move_copy_conting_class();
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v2 = boost::move(v1);
|
||||
v2 = std::move(v1);
|
||||
// Assuring that `move_copy_conting_class` in v1 was moved at least once and was not copied
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_TEST(move_copy_conting_class::copy_count == 0);
|
||||
@@ -155,19 +108,19 @@ void run()
|
||||
variant_II_type v3;
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v1 = boost::move(v3);
|
||||
v1 = std::move(v3);
|
||||
// Assuring that `move_copy_conting_class` in v3 was moved at least once (v1 and v3 have different types)
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
v2 = boost::move(v1);
|
||||
v2 = std::move(v1);
|
||||
// Assuring that `move_copy_conting_class` in v1 was moved at least once (v1 and v3 have different types)
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
variant_I_type v5(boost::move(v1));
|
||||
variant_I_type v5(std::move(v1));
|
||||
// Assuring that `move_copy_conting_class` in v1 was moved at least once and was not copied
|
||||
BOOST_TEST(move_copy_conting_class::moves_count != 0);
|
||||
BOOST_TEST(move_copy_conting_class::copy_count == 0);
|
||||
@@ -187,7 +140,7 @@ void run1()
|
||||
|
||||
move_copy_conting_class c1;
|
||||
typedef boost::variant<int, move_copy_conting_class> variant_I_type;
|
||||
variant_I_type v1(boost::move(c1));
|
||||
variant_I_type v1(std::move(c1));
|
||||
|
||||
// Assuring that `move_copy_conting_class` was not copyied
|
||||
BOOST_TEST(move_copy_conting_class::copy_count == 0);
|
||||
@@ -267,19 +220,16 @@ void run_const_rvalues()
|
||||
v4 = get_string();
|
||||
v5 = get_variant();
|
||||
v6 = get_variant2();
|
||||
v7 = boost::move(v1);
|
||||
v7 = std::move(v1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
struct nothrow_copyable_throw_movable {
|
||||
nothrow_copyable_throw_movable(){}
|
||||
nothrow_copyable_throw_movable(const nothrow_copyable_throw_movable&) BOOST_NOEXCEPT {}
|
||||
nothrow_copyable_throw_movable& operator=(const nothrow_copyable_throw_movable&) BOOST_NOEXCEPT { return *this; }
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
nothrow_copyable_throw_movable(nothrow_copyable_throw_movable&&) BOOST_NOEXCEPT_IF(false) {}
|
||||
nothrow_copyable_throw_movable& operator=(nothrow_copyable_throw_movable&&) BOOST_NOEXCEPT_IF(false) { return *this; }
|
||||
#endif
|
||||
};
|
||||
|
||||
// This test is created to cover the following situation:
|
||||
@@ -320,13 +270,5 @@ int main()
|
||||
run_const_rvalues();
|
||||
run_is_container_compilation_test();
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ > 6)
|
||||
# ifdef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
BOOST_TEST(false &&
|
||||
"Something wrong with macro definitions. GCC-4.7+ is known to work with variadic templates"
|
||||
);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ inline void get_rvref_test()
|
||||
boost::variant<MoveonlyType, int> v;
|
||||
|
||||
v = MoveonlyType();
|
||||
boost::get<MoveonlyType>(boost::move(v));
|
||||
boost::get<MoveonlyType>(std::move(v));
|
||||
|
||||
v = 3;
|
||||
|
||||
@@ -396,7 +396,7 @@ inline void get_rvref_test()
|
||||
boost::relaxed_get<MoveonlyType&>(boost::variant<MoveonlyType, int>());
|
||||
|
||||
v = MoveonlyType();
|
||||
MoveonlyType moved_from_variant(boost::get<MoveonlyType>(boost::move(v)));
|
||||
MoveonlyType moved_from_variant(boost::get<MoveonlyType>(std::move(v)));
|
||||
}
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
|
||||
@@ -135,14 +135,12 @@ int main()
|
||||
arithmetics_t(true)
|
||||
);
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
if_visitor if_vis;
|
||||
BOOST_TEST(
|
||||
boost::apply_visitor(if_vis)(v0, v1, v2)
|
||||
==
|
||||
arithmetics_t(true)
|
||||
);
|
||||
#endif
|
||||
|
||||
|
||||
variant_noncopy_t vnonc[6];
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "boost/variant/variant.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#include <string>
|
||||
@@ -29,7 +28,7 @@ inline void run()
|
||||
var_t v = s;
|
||||
|
||||
// must spit an error at compile-time because of 'std::string&'
|
||||
std::string new_s = boost::strict_get<std::string&>(boost::move(v));
|
||||
std::string new_s = boost::strict_get<std::string&>(std::move(v));
|
||||
UNUSED(new_s);
|
||||
#else
|
||||
BOOST_STATIC_ASSERT_MSG(false, "Dummy compile-time error to pass the test on C++03");
|
||||
|
||||
Reference in New Issue
Block a user