update boost on linux

This commit is contained in:
Bassem Girgis
2019-08-10 16:06:25 -05:00
parent 76ad52be58
commit 861b918727
5363 changed files with 483306 additions and 116507 deletions

View File

@@ -23,7 +23,7 @@ namespace boost {
// Exception thrown when a visitation attempt via apply_visitor fails due
// to invalid visited subtype or contents.
//
struct bad_visit
struct BOOST_SYMBOL_VISIBLE bad_visit
: std::exception
{
public: // std::exception interface

View File

@@ -4,7 +4,7 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) 2002-2003 Eric Friedman
// Copyright (c) 2014 Antony Polukhin
// Copyright (c) 2014-2019 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@@ -14,22 +14,21 @@
#define BOOST_VARIANT_DETAIL_APPLY_VISITOR_BINARY_HPP
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/variant/detail/generic_result_type.hpp>
#include <boost/variant/detail/apply_visitor_unary.hpp>
#if BOOST_WORKAROUND(__EDG__, BOOST_TESTED_AT(302))
#include <boost/utility/enable_if.hpp>
#include <boost/mpl/not.hpp>
#include <boost/type_traits/is_const.hpp>
#endif
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
# 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/move.hpp>
# include <boost/move/utility.hpp>
#endif
namespace boost {
//////////////////////////////////////////////////////////////////////////
@@ -42,7 +41,7 @@ namespace boost {
namespace detail { namespace variant {
template <typename Visitor, typename Value1>
template <typename Visitor, typename Value1, bool MoveSemantics>
class apply_visitor_binary_invoke
{
public: // visitor typedefs
@@ -65,18 +64,38 @@ public: // structors
public: // visitor interfaces
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <typename Value2>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
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));
}
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));
}
#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&);
};
template <typename Visitor, typename Visitable2>
template <typename Visitor, typename Visitable2, bool MoveSemantics>
class apply_visitor_binary_unwrap
{
public: // visitor typedefs
@@ -99,18 +118,51 @@ public: // structors
public: // visitor interfaces
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <typename Value1>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
typename enable_if_c<MoveSemantics && is_same<Value1, Value1>::value, result_type>::type
operator()(Value1&& value1)
{
apply_visitor_binary_invoke<
Visitor
, Value1
, ! ::boost::is_lvalue_reference<Value1>::value
> invoker(visitor_, value1);
return boost::apply_visitor(invoker, ::boost::move(visitable2_));
}
template <typename Value1>
typename disable_if_c<MoveSemantics && is_same<Value1, Value1>::value, result_type>::type
operator()(Value1&& value1)
{
apply_visitor_binary_invoke<
Visitor
, Value1
, ! ::boost::is_lvalue_reference<Value1>::value
> invoker(visitor_, value1);
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&);
@@ -122,61 +174,66 @@ private:
// nonconst-visitor version:
//
#if !BOOST_WORKAROUND(__EDG__, BOOST_TESTED_AT(302))
# define BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(V) \
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename V::result_type) \
/**/
#else // EDG-based compilers
# define BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(V) \
typename enable_if< \
mpl::not_< is_const< V > > \
, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename V::result_type) \
>::type \
/**/
#endif // EDG-based compilers workaround
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <typename Visitor, typename Visitable1, typename Visitable2>
inline
BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(Visitor)
apply_visitor(
Visitor& visitor
, Visitable1& visitable1, Visitable2& visitable2
)
inline typename Visitor::result_type
apply_visitor( Visitor& visitor, Visitable1&& visitable1, Visitable2&& visitable2)
{
::boost::detail::variant::apply_visitor_binary_unwrap<
Visitor, Visitable2
Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
> unwrapper(visitor, visitable2);
return boost::apply_visitor(unwrapper, ::boost::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);
}
#undef BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE
#endif
//
// const-visitor version:
//
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <typename Visitor, typename Visitable1, typename Visitable2>
inline
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(
typename Visitor::result_type
)
apply_visitor(
const Visitor& visitor
, Visitable1& visitable1, Visitable2& 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
const Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
> unwrapper(visitor, visitable2);
return boost::apply_visitor(unwrapper, ::boost::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)
@@ -188,7 +245,7 @@ apply_visitor(
namespace detail { namespace variant {
template <typename Visitor, typename Value1>
template <typename Visitor, typename Value1, bool MoveSemantics>
class apply_visitor_binary_invoke_cpp14
{
Visitor& visitor_;
@@ -205,16 +262,22 @@ public: // structors
public: // visitor interfaces
template <typename Value2>
decltype(auto) operator()(Value2& value2)
decltype(auto) operator()(Value2&& value2, typename enable_if_c<MoveSemantics && is_same<Value2, Value2>::value>::type* = 0)
{
return visitor_(value1_, value2);
return visitor_(::boost::move(value1_), ::boost::forward<Value2>(value2));
}
template <typename Value2>
decltype(auto) operator()(Value2&& value2, typename disable_if_c<MoveSemantics && is_same<Value2, Value2>::value>::type* = 0)
{
return visitor_(value1_, ::boost::forward<Value2>(value2));
}
private:
apply_visitor_binary_invoke_cpp14& operator=(const apply_visitor_binary_invoke_cpp14&);
};
template <typename Visitor, typename Visitable2>
template <typename Visitor, typename Visitable2, bool MoveSemantics>
class apply_visitor_binary_unwrap_cpp14
{
Visitor& visitor_;
@@ -231,11 +294,24 @@ public: // structors
public: // visitor interfaces
template <typename Value1>
decltype(auto) operator()(Value1& value1)
decltype(auto) operator()(Value1&& value1, typename enable_if_c<MoveSemantics && is_same<Value1, Value1>::value>::type* = 0)
{
apply_visitor_binary_invoke_cpp14<
Visitor
, Value1
, ! ::boost::is_lvalue_reference<Value1>::value
> invoker(visitor_, value1);
return boost::apply_visitor(invoker, ::boost::move(visitable2_));
}
template <typename Value1>
decltype(auto) operator()(Value1&& value1, typename disable_if_c<MoveSemantics && is_same<Value1, Value1>::value>::type* = 0)
{
apply_visitor_binary_invoke_cpp14<
Visitor
, Value1
, ! ::boost::is_lvalue_reference<Value1>::value
> invoker(visitor_, value1);
return boost::apply_visitor(invoker, visitable2_);
@@ -248,31 +324,32 @@ private:
}} // namespace detail::variant
template <typename Visitor, typename Visitable1, typename Visitable2>
inline decltype(auto) apply_visitor(Visitor& visitor, Visitable1& visitable1, Visitable2& visitable2,
inline decltype(auto) apply_visitor(Visitor& visitor, Visitable1&& visitable1, Visitable2&& visitable2,
typename boost::disable_if<
boost::detail::variant::has_result_type<Visitor>
>::type* = 0)
{
::boost::detail::variant::apply_visitor_binary_unwrap_cpp14<
Visitor, Visitable2
Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
> unwrapper(visitor, visitable2);
return boost::apply_visitor(unwrapper, visitable1);
return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
}
template <typename Visitor, typename Visitable1, typename Visitable2>
inline decltype(auto) apply_visitor(const Visitor& visitor, Visitable1& visitable1, Visitable2& visitable2,
inline decltype(auto) apply_visitor(const Visitor& visitor, Visitable1&& visitable1, Visitable2&& visitable2,
typename boost::disable_if<
boost::detail::variant::has_result_type<Visitor>
>::type* = 0)
{
::boost::detail::variant::apply_visitor_binary_unwrap_cpp14<
const Visitor, Visitable2
const Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
> unwrapper(visitor, visitable2);
return boost::apply_visitor(unwrapper, visitable1);
return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
}
#endif // !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
} // namespace boost

View File

@@ -13,8 +13,6 @@
#ifndef BOOST_VARIANT_DETAIL_APPLY_VISITOR_DELAYED_HPP
#define BOOST_VARIANT_DETAIL_APPLY_VISITOR_DELAYED_HPP
#include <boost/variant/detail/generic_result_type.hpp>
#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
@@ -63,8 +61,7 @@ public: // structors
public: // N-ary visitor interface
template <typename... Visitables>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
operator()(Visitables&... visitables) const
result_type operator()(Visitables&... visitables) const
{
return apply_visitor(visitor_, visitables...);
}
@@ -74,8 +71,7 @@ public: // N-ary visitor interface
public: // unary visitor interface
template <typename Visitable>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
operator()(Visitable& visitable) const
result_type operator()(Visitable& visitable) const
{
return apply_visitor(visitor_, visitable);
}
@@ -83,8 +79,7 @@ public: // unary visitor interface
public: // binary visitor interface
template <typename Visitable1, typename Visitable2>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
operator()(Visitable1& visitable1, Visitable2& visitable2) const
result_type operator()(Visitable1& visitable1, Visitable2& visitable2) const
{
return apply_visitor(visitor_, visitable1, visitable2);
}

View File

@@ -4,7 +4,7 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) 2002-2003 Eric Friedman
// Copyright (c) 2014 Antony Polukhin
// Copyright (c) 2014-2019 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@@ -14,14 +14,7 @@
#define BOOST_VARIANT_DETAIL_APPLY_VISITOR_UNARY_HPP
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/variant/detail/generic_result_type.hpp>
#if BOOST_WORKAROUND(__EDG__, BOOST_TESTED_AT(302))
#include <boost/core/enable_if.hpp>
#include <boost/mpl/not.hpp>
#include <boost/type_traits/is_const.hpp>
#endif
#include <boost/move/utility.hpp>
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
# include <boost/mpl/distance.hpp>
@@ -30,6 +23,7 @@
# include <boost/mpl/size.hpp>
# include <boost/utility/declval.hpp>
# include <boost/core/enable_if.hpp>
# include <boost/type_traits/remove_reference.hpp>
# include <boost/variant/detail/has_result_type.hpp>
#endif
@@ -45,47 +39,45 @@ namespace boost {
// nonconst-visitor version:
//
#if !BOOST_WORKAROUND(__EDG__, BOOST_TESTED_AT(302))
# define BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(V) \
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename V::result_type) \
/**/
#else // EDG-based compilers
# define BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(V) \
typename enable_if< \
mpl::not_< is_const< V > > \
, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename V::result_type) \
>::type \
/**/
#endif // EDG-based compilers workaround
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <typename Visitor, typename Visitable>
inline
BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(Visitor)
inline typename Visitor::result_type
apply_visitor(Visitor& visitor, Visitable&& visitable)
{
return ::boost::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);
}
#undef BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE
#endif
//
// const-visitor version:
//
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <typename Visitor, typename Visitable>
inline
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
inline typename Visitor::result_type
apply_visitor(const Visitor& visitor, Visitable&& visitable)
{
return ::boost::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)
#define BOOST_VARIANT_HAS_DECLTYPE_APPLY_VISITOR_RETURN_TYPE
// C++14
namespace detail { namespace variant {
@@ -99,71 +91,49 @@ struct result_multideduce1 {
begin_it, boost::mpl::int_<boost::mpl::size<types>::type::value - 1>
>::type last_it;
// For metaprogramming purposes ONLY! Do not use this method (and class) at runtime!
static Visitor& vis() BOOST_NOEXCEPT {
// Functions that work with lambdas must be defined in same translation unit.
// Because of that, we can not use `boost::decval<Visitor&>()` here.
Visitor&(*f)() = 0; // pointer to function
return f();
}
static decltype(auto) deduce_impl(last_it, unsigned /*helper*/) {
typedef typename boost::mpl::deref<last_it>::type value_t;
return vis()( boost::declval< value_t& >() );
}
template <class It>
static decltype(auto) deduce_impl(It, unsigned helper) {
template <class It, class Dummy = void> // avoid explicit specialization in class scope
struct deduce_impl {
typedef typename boost::mpl::next<It>::type next_t;
typedef typename boost::mpl::deref<It>::type value_t;
if (helper == boost::mpl::distance<begin_it, It>::type::value) {
return deduce_impl(next_t(), ++helper);
}
typedef decltype(true ? boost::declval< Visitor& >()( boost::declval< value_t >() )
: boost::declval< typename deduce_impl<next_t>::type >()) type;
};
return vis()( boost::declval< value_t& >() );
}
template <class Dummy>
struct deduce_impl<last_it, Dummy> {
typedef typename boost::mpl::deref<last_it>::type value_t;
typedef decltype(boost::declval< Visitor& >()( boost::declval< value_t >() )) type;
};
static decltype(auto) deduce() {
return deduce_impl(begin_it(), 0);
}
typedef typename deduce_impl<begin_it>::type type;
};
template <class Visitor, class Variant>
struct result_wrapper1
{
typedef decltype(result_multideduce1<Visitor, Variant>::deduce()) result_type;
typedef typename result_multideduce1<Visitor, Variant>::type result_type;
Visitor& visitor_;
explicit result_wrapper1(Visitor& visitor) BOOST_NOEXCEPT
: visitor_(visitor)
Visitor&& visitor_;
explicit result_wrapper1(Visitor&& visitor) BOOST_NOEXCEPT
: visitor_(::boost::forward<Visitor>(visitor))
{}
template <class T>
result_type operator()(T& val) const {
return visitor_(val);
result_type operator()(T&& val) const {
return visitor_(::boost::forward<T>(val));
}
};
}} // namespace detail::variant
template <typename Visitor, typename Visitable>
inline decltype(auto) apply_visitor(Visitor& visitor, Visitable& visitable,
inline decltype(auto) apply_visitor(Visitor&& visitor, Visitable&& visitable,
typename boost::disable_if<
boost::detail::variant::has_result_type<Visitor>
>::type* = 0)
{
boost::detail::variant::result_wrapper1<Visitor, Visitable> cpp14_vis(visitor);
return visitable.apply_visitor(cpp14_vis);
}
template <typename Visitor, typename Visitable>
inline decltype(auto) apply_visitor(const Visitor& visitor, Visitable& visitable,
typename boost::disable_if<
boost::detail::variant::has_result_type<Visitor>
>::type* = 0)
{
boost::detail::variant::result_wrapper1<const Visitor, Visitable> cpp14_vis(visitor);
return visitable.apply_visitor(cpp14_vis);
boost::detail::variant::result_wrapper1<Visitor, typename remove_reference<Visitable>::type> cpp14_vis(::boost::forward<Visitor>(visitor));
return ::boost::forward<Visitable>(visitable).apply_visitor(cpp14_vis);
}
#endif // !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)

View File

@@ -4,7 +4,7 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) 2003 Eric Friedman
// Copyright (c) 2016 Antony Polukhin
// Copyright (c) 2016-2019 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at

View File

@@ -3,7 +3,7 @@
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2014-2015 Antony Polukhin
// Copyright (c) 2014-2019 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at

View File

@@ -4,7 +4,7 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) 2003 Eric Friedman
// Copyright (c) 2015-2016 Antony Polukhin
// Copyright (c) 2015-2019 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@@ -14,7 +14,6 @@
#define BOOST_VARIANT_DETAIL_FORCED_RETURN_HPP
#include <boost/config.hpp>
#include <boost/variant/detail/generic_result_type.hpp>
#include <boost/assert.hpp>
#include <cstdlib> // std::abort
@@ -39,8 +38,7 @@ BOOST_NORETURN inline void forced_return_no_return() { // fixes `must return a v
// compile-time requirement of returning a result value.
//
template <typename T>
BOOST_NORETURN inline
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T)
BOOST_NORETURN inline T
forced_return()
{
// logical error: should never be here! (see above)
@@ -49,7 +47,7 @@ forced_return()
forced_return_no_return();
#ifdef BOOST_NO_NORETURN
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T) (*dummy)() = 0;
T (*dummy)() = 0;
return dummy();
#endif
}

View File

@@ -1,88 +0,0 @@
//-----------------------------------------------------------------------------
// boost variant/detail/generic_result_type.hpp header file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2003
// Eric Friedman
//
// 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_GENERIC_RESULT_TYPE_HPP
#define BOOST_VARIANT_DETAIL_GENERIC_RESULT_TYPE_HPP
#include <boost/config.hpp>
//////////////////////////////////////////////////////////////////////////
// (workaround) macro BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE
//
// On compilers with BOOST_NO_VOID_RETURNS, this macro provides a route
// to a single syntax for dealing with template functions that may (but
// not necessarily) return nothing (i.e. void).
//
// BOOST_VARIANT_AUX_RETURN_VOID provided for compilers w/ (erroneous?)
// warnings about non-void functions not returning a value.
//
#if !defined(BOOST_NO_VOID_RETURNS)
#define BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T) \
T \
/**/
#define BOOST_VARIANT_AUX_RETURN_VOID \
/**/
#define BOOST_VARIANT_AUX_RETURN_VOID_TYPE \
void \
/**/
#else // defined(BOOST_NO_VOID_RETURNS)
namespace boost {
namespace detail { namespace variant {
struct fake_return_void
{
fake_return_void()
{
}
template <typename T>
fake_return_void(const T&)
{
}
};
template <typename T>
struct no_void_returns_helper
{
typedef T type;
};
template <>
struct no_void_returns_helper<void>
{
typedef fake_return_void type;
};
}} // namespace detail::variant
} // namespace boost
#define BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T) \
BOOST_DEDUCED_TYPENAME \
::boost::detail::variant::no_void_returns_helper< T >::type \
/**/
#define BOOST_VARIANT_AUX_RETURN_VOID \
return ::boost::detail::variant::fake_return_void() \
/**/
#define BOOST_VARIANT_AUX_RETURN_VOID_TYPE \
::boost::detail::variant::fake_return_void
#endif // BOOST_NO_VOID_RETURNS workaround
#endif // BOOST_VARIANT_DETAIL_GENERIC_RESULT_TYPE_HPP

View File

@@ -3,7 +3,7 @@
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2014-2015 Antony Polukhin
// Copyright (c) 2014-2019 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at

View File

@@ -3,8 +3,7 @@
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2011
// Antony Polukhin
// Copyright (c) 2011-2019 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at

View File

@@ -4,7 +4,7 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) 2002-2003 Eric Friedman, Itay Maman
// Copyright (c) 2013 Antony Polukhin
// Copyright (c) 2013-2019 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at

View File

@@ -5,7 +5,7 @@
//
// Copyright (c) 2002-2003 Eric Friedman
// Copyright (c) 2002 by Andrei Alexandrescu
// Copyright (c) 2013-2014 Antony Polukhin
// Copyright (c) 2013-2019 Antony Polukhin
//
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file

View File

@@ -18,6 +18,9 @@
#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/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"
@@ -41,10 +44,34 @@ namespace detail { namespace variant {
: index_sequence<I...>
{};
template <class... Types>
std::tuple<Types&...> forward_as_tuple_simple(Types&... args) BOOST_NOEXCEPT
template <typename T_, bool MoveSemantics_>
struct MoveableWrapper //Just a reference with some metadata
{
return std::tuple<Types&...>(args...);
typedef T_ T;
static constexpr bool MoveSemantics = MoveSemantics_;
T& v;
};
template <typename Tp, bool MoveSemantics>
MoveableWrapper<Tp, MoveSemantics>
wrap(Tp& t)
{
return MoveableWrapper<Tp, MoveSemantics>{t};
}
template <typename Wrapper>
typename enable_if_c<Wrapper::MoveSemantics, typename Wrapper::T>::type
unwrap(Wrapper& w)
{
return ::boost::move(w.v);
}
template <typename Wrapper>
typename disable_if_c<Wrapper::MoveSemantics, typename Wrapper::T>::type &
unwrap(Wrapper& w)
{
return w.v;
}
// Implementing some of the helper tuple methods
@@ -64,7 +91,6 @@ namespace detail { namespace variant {
}
// Forward declaration
template <typename Visitor, typename Visitables, typename... Values>
class one_by_one_visitor_and_value_referer;
@@ -72,7 +98,7 @@ namespace detail { namespace variant {
template <typename Visitor, typename Visitables, typename... Values>
inline one_by_one_visitor_and_value_referer<Visitor, Visitables, Values... >
make_one_by_one_visitor_and_value_referer(
Visitor& visitor, Visitables visitables, std::tuple<Values&...> values
Visitor& visitor, Visitables visitables, std::tuple<Values...> values
)
{
return one_by_one_visitor_and_value_referer<Visitor, Visitables, Values... > (
@@ -84,12 +110,12 @@ namespace detail { namespace variant {
class one_by_one_visitor_and_value_referer
{
Visitor& visitor_;
std::tuple<Values&...> values_;
std::tuple<Values...> values_;
Visitables visitables_;
public: // structors
one_by_one_visitor_and_value_referer(
Visitor& visitor, Visitables visitables, std::tuple<Values&...> values
Visitor& visitor, Visitables visitables, std::tuple<Values...> values
) BOOST_NOEXCEPT
: visitor_(visitor)
, values_(values)
@@ -100,15 +126,15 @@ namespace detail { namespace variant {
typedef typename Visitor::result_type result_type;
template <typename Value>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type) operator()(Value& value) const
result_type operator()(Value&& value) const
{
return ::boost::apply_visitor(
make_one_by_one_visitor_and_value_referer(
visitor_,
tuple_tail(visitables_),
std::tuple_cat(values_, std::tuple<Value&>(value))
std::tuple_cat(values_, std::make_tuple(wrap<Value, ! ::boost::is_lvalue_reference<Value>::value>(value)))
)
, std::get<0>(visitables_) // getting Head element
, unwrap(std::get<0>(visitables_)) // getting Head element
);
}
@@ -120,11 +146,11 @@ namespace detail { namespace variant {
class one_by_one_visitor_and_value_referer<Visitor, std::tuple<>, Values...>
{
Visitor& visitor_;
std::tuple<Values&...> values_;
std::tuple<Values...> values_;
public:
one_by_one_visitor_and_value_referer(
Visitor& visitor, std::tuple<> /*visitables*/, std::tuple<Values&...> values
Visitor& visitor, std::tuple<> /*visitables*/, std::tuple<Values...> values
) BOOST_NOEXCEPT
: visitor_(visitor)
, values_(values)
@@ -133,15 +159,15 @@ namespace detail { namespace variant {
typedef typename Visitor::result_type result_type;
template <class Tuple, std::size_t... I>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type) do_call(Tuple t, index_sequence<I...>) const {
return visitor_(std::get<I>(t)...);
result_type do_call(Tuple t, index_sequence<I...>) const {
return visitor_(unwrap(std::get<I>(t))...);
}
template <typename Value>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type) operator()(Value& value) const
result_type operator()(Value&& value) const
{
return do_call(
std::tuple_cat(values_, std::tuple<Value&>(value)),
std::tuple_cat(values_, std::make_tuple(wrap<Value, ! ::boost::is_lvalue_reference<Value>::value>(value))),
make_index_sequence<sizeof...(Values) + 1>()
);
}
@@ -150,31 +176,39 @@ namespace detail { namespace variant {
}} // namespace detail::variant
template <class Visitor, class T1, class T2, class T3, class... TN>
inline BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
apply_visitor(const Visitor& visitor, T1& v1, T2& v2, T3& v3, TN&... vn)
inline typename Visitor::result_type
apply_visitor(const Visitor& visitor, T1&& v1, T2&& v2, T3&& v3, TN&&... vn)
{
return ::boost::apply_visitor(
::boost::detail::variant::make_one_by_one_visitor_and_value_referer(
visitor,
::boost::detail::variant::forward_as_tuple_simple(v2, v3, vn...),
std::make_tuple(
::boost::detail::variant::wrap<T2, ! ::boost::is_lvalue_reference<T2>::value>(v2),
::boost::detail::variant::wrap<T3, ! ::boost::is_lvalue_reference<T3>::value>(v3),
::boost::detail::variant::wrap<TN, ! ::boost::is_lvalue_reference<TN>::value>(vn)...
),
std::tuple<>()
),
v1
);
),
::boost::forward<T1>(v1)
);
}
template <class Visitor, class T1, class T2, class T3, class... TN>
inline BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
apply_visitor(Visitor& visitor, T1& v1, T2& v2, T3& v3, TN&... vn)
inline typename Visitor::result_type
apply_visitor(Visitor& visitor, T1&& v1, T2&& v2, T3&& v3, TN&&... vn)
{
return ::boost::apply_visitor(
::boost::detail::variant::make_one_by_one_visitor_and_value_referer(
visitor,
::boost::detail::variant::forward_as_tuple_simple(v2, v3, vn...),
std::make_tuple(
::boost::detail::variant::wrap<T2, ! ::boost::is_lvalue_reference<T2>::value>(v2),
::boost::detail::variant::wrap<T3, ! ::boost::is_lvalue_reference<T3>::value>(v3),
::boost::detail::variant::wrap<TN, ! ::boost::is_lvalue_reference<TN>::value>(vn)...
),
std::tuple<>()
),
v1
);
),
::boost::forward<T1>(v1)
);
}
} // namespace boost

View File

@@ -30,7 +30,7 @@ namespace detail { namespace variant {
template <typename Visitor, typename Visitables, typename... Values>
inline one_by_one_visitor_and_value_referer_cpp14<Visitor, Visitables, Values... >
make_one_by_one_visitor_and_value_referer_cpp14(
Visitor& visitor, Visitables visitables, std::tuple<Values&...> values
Visitor& visitor, Visitables visitables, std::tuple<Values...> values
)
{
return one_by_one_visitor_and_value_referer_cpp14<Visitor, Visitables, Values... > (
@@ -42,12 +42,12 @@ namespace detail { namespace variant {
class one_by_one_visitor_and_value_referer_cpp14
{
Visitor& visitor_;
std::tuple<Values&...> values_;
std::tuple<Values...> values_;
Visitables visitables_;
public: // structors
one_by_one_visitor_and_value_referer_cpp14(
Visitor& visitor, Visitables visitables, std::tuple<Values&...> values
Visitor& visitor, Visitables visitables, std::tuple<Values...> values
) BOOST_NOEXCEPT
: visitor_(visitor)
, values_(values)
@@ -56,15 +56,15 @@ namespace detail { namespace variant {
public: // visitor interfaces
template <typename Value>
decltype(auto) operator()(Value& value) const
decltype(auto) operator()(Value&& value) const
{
return ::boost::apply_visitor(
make_one_by_one_visitor_and_value_referer_cpp14(
visitor_,
tuple_tail(visitables_),
std::tuple_cat(values_, std::tuple<Value&>(value))
std::tuple_cat(values_, std::make_tuple(wrap<Value, ! ::boost::is_lvalue_reference<Value>::value>(value)))
)
, std::get<0>(visitables_) // getting Head element
, unwrap(std::get<0>(visitables_)) // getting Head element
);
}
@@ -76,11 +76,11 @@ namespace detail { namespace variant {
class one_by_one_visitor_and_value_referer_cpp14<Visitor, std::tuple<>, Values...>
{
Visitor& visitor_;
std::tuple<Values&...> values_;
std::tuple<Values...> values_;
public:
one_by_one_visitor_and_value_referer_cpp14(
Visitor& visitor, std::tuple<> /*visitables*/, std::tuple<Values&...> values
Visitor& visitor, std::tuple<> /*visitables*/, std::tuple<Values...> values
) BOOST_NOEXCEPT
: visitor_(visitor)
, values_(values)
@@ -88,14 +88,14 @@ namespace detail { namespace variant {
template <class Tuple, std::size_t... I>
decltype(auto) do_call(Tuple t, index_sequence<I...>) const {
return visitor_(std::get<I>(t)...);
return visitor_(unwrap(std::get<I>(t))...);
}
template <typename Value>
decltype(auto) operator()(Value& value) const
decltype(auto) operator()(Value&& value) const
{
return do_call(
std::tuple_cat(values_, std::tuple<Value&>(value)),
std::tuple_cat(values_, std::make_tuple(wrap<Value, ! ::boost::is_lvalue_reference<Value>::value>(value))),
make_index_sequence<sizeof...(Values) + 1>()
);
}
@@ -104,7 +104,7 @@ namespace detail { namespace variant {
}} // namespace detail::variant
template <class Visitor, class T1, class T2, class T3, class... TN>
inline decltype(auto) apply_visitor(const Visitor& visitor, T1& v1, T2& v2, T3& v3, TN&... vn,
inline decltype(auto) apply_visitor(const Visitor& visitor, T1&& v1, T2&& v2, T3&& v3, TN&&... vn,
typename boost::disable_if<
boost::detail::variant::has_result_type<Visitor>
>::type* = 0)
@@ -112,16 +112,20 @@ namespace detail { namespace variant {
return boost::apply_visitor(
::boost::detail::variant::make_one_by_one_visitor_and_value_referer_cpp14(
visitor,
::boost::detail::variant::forward_as_tuple_simple(v2, v3, vn...),
std::make_tuple(
::boost::detail::variant::wrap<T2, ! ::boost::is_lvalue_reference<T2>::value>(v2),
::boost::detail::variant::wrap<T3, ! ::boost::is_lvalue_reference<T3>::value>(v3),
::boost::detail::variant::wrap<TN, ! ::boost::is_lvalue_reference<TN>::value>(vn)...
),
std::tuple<>()
),
v1
::boost::forward<T1>(v1)
);
}
template <class Visitor, class T1, class T2, class T3, class... TN>
inline decltype(auto) apply_visitor(Visitor& visitor, T1& v1, T2& v2, T3& v3, TN&... vn,
inline decltype(auto) apply_visitor(Visitor& visitor, T1&& v1, T2&& v2, T3&& v3, TN&&... vn,
typename boost::disable_if<
boost::detail::variant::has_result_type<Visitor>
>::type* = 0)
@@ -129,10 +133,14 @@ namespace detail { namespace variant {
return ::boost::apply_visitor(
::boost::detail::variant::make_one_by_one_visitor_and_value_referer_cpp14(
visitor,
::boost::detail::variant::forward_as_tuple_simple(v2, v3, vn...),
std::make_tuple(
::boost::detail::variant::wrap<T2, ! ::boost::is_lvalue_reference<T2>::value>(v2),
::boost::detail::variant::wrap<T3, ! ::boost::is_lvalue_reference<T3>::value>(v3),
::boost::detail::variant::wrap<TN, ! ::boost::is_lvalue_reference<TN>::value>(vn)...
),
std::tuple<>()
),
v1
::boost::forward<T1>(v1)
);
}

View File

@@ -67,7 +67,7 @@ namespace detail { namespace variant {
#define BOOST_VARIANT_VISIT(z, n, data) \
template <BOOST_PP_ENUM_PARAMS(BOOST_PP_ADD(n, 1), class VisitableUnwrapped)> \
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type) operator()( \
result_type operator()( \
BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ADD(n, 1), VisitableUnwrapped, & vis) \
) const \
{ \
@@ -119,7 +119,7 @@ BOOST_PP_REPEAT( BOOST_PP_SUB(BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS, 2), BOOST_V
#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_VARIANT_AUX_GENERIC_RESULT_TYPE(BOOST_DEDUCED_TYPENAME Visitor::result_type) apply_visitor( \
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) \
) \
{ \

View File

@@ -145,7 +145,32 @@ struct substitute<
Ts, Dest, Source
>::type...> type;
};
#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
//
// function specializations
//
template <
typename R
, typename... A
, typename Dest
, typename Source
>
struct substitute<
R (*)(A...)
, Dest
, Source
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>)
>
{
private:
typedef typename substitute< R, Dest, Source >::type r;
public:
typedef r (*type)(typename substitute<
A, Dest, Source
>::type...);
};
#else
#define BOOST_VARIANT_AUX_SUBSTITUTE_TYPEDEF_IMPL(N) \
typedef typename substitute< \
@@ -164,6 +189,7 @@ struct substitute<
#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

View File

@@ -18,7 +18,6 @@
#include <boost/variant/detail/backup_holder.hpp>
#include <boost/variant/detail/cast_storage.hpp>
#include <boost/variant/detail/forced_return.hpp>
#include <boost/variant/detail/generic_result_type.hpp>
#include <boost/variant/variant_fwd.hpp> // for BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
#include <boost/mpl/eval_if.hpp>
@@ -102,8 +101,7 @@ struct visitation_impl_step< LastIter,LastIter >
//
template <typename Visitor, typename VoidPtrCV, typename T>
inline
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
inline typename Visitor::result_type
visitation_impl_invoke_impl(
int, Visitor& visitor, VoidPtrCV storage, T*
, mpl::true_// never_uses_backup
@@ -115,8 +113,7 @@ visitation_impl_invoke_impl(
}
template <typename Visitor, typename VoidPtrCV, typename T>
inline
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
inline typename Visitor::result_type
visitation_impl_invoke_impl(
int internal_which, Visitor& visitor, VoidPtrCV storage, T*
, mpl::false_// never_uses_backup
@@ -137,8 +134,7 @@ visitation_impl_invoke_impl(
}
template <typename Visitor, typename VoidPtrCV, typename T, typename NoBackupFlag>
inline
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
inline typename Visitor::result_type
visitation_impl_invoke(
int internal_which, Visitor& visitor, VoidPtrCV storage, T* t
, NoBackupFlag
@@ -158,8 +154,7 @@ visitation_impl_invoke(
}
template <typename Visitor, typename VoidPtrCV, typename NBF>
inline
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
inline typename Visitor::result_type
visitation_impl_invoke(int, Visitor&, VoidPtrCV, apply_visitor_unrolled*, NBF, long)
{
// should never be here at runtime!
@@ -178,8 +173,7 @@ template <
, typename Visitor, typename VPCV
, typename NBF
>
inline
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
inline typename Visitor::result_type
visitation_impl(
int, int, Visitor&, VPCV
, mpl::true_ // is_apply_visitor_unrolled
@@ -196,8 +190,7 @@ template <
, typename Visitor, typename VoidPtrCV
, typename NoBackupFlag
>
inline
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
inline typename Visitor::result_type
visitation_impl(
const int internal_which, const int logical_which
, Visitor& visitor, VoidPtrCV storage

View File

@@ -4,7 +4,7 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) 2003 Eric Friedman, Itay Maman
// Copyright (c) 2014 Antony Polukhin
// Copyright (c) 2014-2019 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@@ -22,9 +22,11 @@
#include <boost/utility/addressof.hpp>
#include <boost/variant/variant_fwd.hpp>
#include <boost/variant/detail/element_index.hpp>
#include <boost/variant/detail/move.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/add_pointer.hpp>
#include <boost/type_traits/is_lvalue_reference.hpp>
namespace boost {
@@ -170,7 +172,34 @@ relaxed_get(
return *result;
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
#if defined(BOOST_MSVC) && (_MSC_VER < 1900) // MSVC-2014 has fixed the incorrect diagnostics.
# pragma warning(push)
# pragma warning(disable: 4172) // returning address of local variable or temporary
#endif
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
inline
U&&
relaxed_get(
boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >&& operand
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
)
{
typedef typename add_pointer<U>::type U_ptr;
U_ptr result = relaxed_get<U>(boost::addressof(operand));
if (!result)
boost::throw_exception(bad_get());
return static_cast<U&&>(*result);
}
#if defined(BOOST_MSVC) && (_MSC_VER < 1900)
# pragma warning(pop)
#endif
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// strict_get<U>(variant) methods
@@ -243,6 +272,30 @@ strict_get(
return relaxed_get<U>(operand);
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
inline
U&&
strict_get(
boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >&& operand
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
)
{
BOOST_STATIC_ASSERT_MSG(
(!boost::is_lvalue_reference<U>::value),
"remove ampersand '&' from template type U in boost::get<U>(boost::variant<T...>&&) "
);
BOOST_STATIC_ASSERT_MSG(
(boost::detail::variant::holds_element<boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >, U >::value),
"boost::variant does not contain specified type U, "
"call to boost::get<U>(const boost::variant<T...>&) will always throw boost::bad_get exception"
);
return relaxed_get<U>(detail::variant::move(operand));
}
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// get<U>(variant) methods
//
@@ -308,6 +361,23 @@ get(
#endif
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
inline
U&&
get(
boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >&& operand
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
)
{
#ifdef BOOST_VARIANT_USE_RELAXED_GET_BY_DEFAULT
return relaxed_get<U>(detail::variant::move(operand));
#else
return strict_get<U>(detail::variant::move(operand));
#endif
}
#endif
} // namespace boost
#endif // BOOST_VARIANT_GET_HPP

View File

@@ -3,7 +3,7 @@
//
// See http://www.boost.org for most recent version, including documentation.
//
// Copyright Antony Polukhin, 2013-2014.
// Copyright (c) 2013-2019 Antony Polukhin.
//
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file

View File

@@ -3,7 +3,7 @@
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2013-2017 Antony Polukhin
// Copyright (c) 2013-2019 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@@ -25,6 +25,7 @@
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/add_pointer.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/type_traits/is_const.hpp>
namespace boost {

View File

@@ -4,7 +4,7 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) 2003 Eric Friedman
// Copyright (c) 2013 Antony Polukhin
// Copyright (c) 2013-2019 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at

View File

@@ -4,7 +4,7 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) 2002 Eric Friedman, Itay Maman
// Copyright (c) 2016-2017 Antony Polukhin
// Copyright (c) 2016-2019 Antony Polukhin
//
// Portions Copyright (C) 2002 David Abrahams
//

View File

@@ -50,10 +50,8 @@ public: // typedefs
protected: // for use as base class only
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)
static_visitor() = default;
~static_visitor() = default;
#else
static_visitor() BOOST_NOEXCEPT { }
~static_visitor() BOOST_NOEXCEPT { }
#endif
};

View File

@@ -4,7 +4,7 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) 2002-2003 Eric Friedman, Itay Maman
// Copyright (c) 2012-2016 Antony Polukhin
// Copyright (c) 2012-2019 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@@ -33,14 +33,13 @@
#include <boost/variant/detail/visitation_impl.hpp>
#include <boost/variant/detail/hash_variant.hpp>
#include <boost/variant/detail/generic_result_type.hpp>
#include <boost/variant/detail/move.hpp>
#include <boost/detail/no_exceptions_support.hpp>
#include <boost/detail/reference_content.hpp>
#include <boost/aligned_storage.hpp>
#include <boost/blank.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/integer/common_factor_ct.hpp>
#include <boost/static_assert.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/repeat.hpp>
@@ -71,10 +70,12 @@
#include <boost/mpl/front.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/insert_range.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/iterator_range.hpp>
#include <boost/mpl/iter_fold_if.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/logical.hpp>
#include <boost/mpl/max_element.hpp>
#include <boost/mpl/next.hpp>
@@ -143,7 +144,7 @@ struct add_alignment
template <typename State, typename Item>
struct apply
: mpl::size_t<
::boost::math::static_lcm<
::boost::integer::static_lcm<
BOOST_MPL_AUX_VALUE_WKND(State)::value
, ::boost::alignment_of<Item>::value
>::value
@@ -379,17 +380,14 @@ struct destroyer
public: // visitor interfaces
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(T& operand, int) const BOOST_NOEXCEPT
void internal_visit(T& operand, int) const BOOST_NOEXCEPT
{
operand.~T(); // must be noexcept
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0551)) || \
BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
operand; // suppresses warnings
(void)operand; // suppresses warnings
#endif
BOOST_VARIANT_AUX_RETURN_VOID;
}
};
@@ -443,27 +441,21 @@ public: // structors
public: // internal visitor interface
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(boost::detail::variant::backup_holder<T>& operand, long) const
void internal_visit(boost::detail::variant::backup_holder<T>& operand, long) const
{
new(storage_) T( operand.get() );
BOOST_VARIANT_AUX_RETURN_VOID;
}
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(const boost::detail::variant::backup_holder<T>& operand, long) const
void internal_visit(const boost::detail::variant::backup_holder<T>& operand, long) const
{
new(storage_) T( operand.get() );
BOOST_VARIANT_AUX_RETURN_VOID;
}
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(const T& operand, int) const
void internal_visit(const T& operand, int) const
{
new(storage_) T(operand);
BOOST_VARIANT_AUX_RETURN_VOID;
}
};
@@ -491,19 +483,15 @@ public: // structors
public: // internal visitor interface
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(boost::detail::variant::backup_holder<T>& operand, long) const
void internal_visit(boost::detail::variant::backup_holder<T>& operand, long) const
{
new(storage_) T( ::boost::detail::variant::move(operand.get()) );
BOOST_VARIANT_AUX_RETURN_VOID;
}
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(T& operand, int) const BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(T(boost::declval<T>())))
void internal_visit(T& operand, int) const BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(T(boost::declval<T>())))
{
new(storage_) T(::boost::detail::variant::move(operand));
BOOST_VARIANT_AUX_RETURN_VOID;
}
};
#endif
@@ -531,26 +519,21 @@ public: // structors
public: // internal visitor interfaces
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(backup_holder<T>& lhs_content, long) const
void internal_visit(backup_holder<T>& lhs_content, long) const
{
lhs_content.get()
= static_cast< const backup_holder<T>* >(rhs_storage_)->get();
BOOST_VARIANT_AUX_RETURN_VOID;
}
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(const backup_holder<T>& lhs_content, long) const
void internal_visit(const backup_holder<T>& lhs_content, long) const
{
lhs_content.get()
= static_cast< const backup_holder<T>* >(rhs_storage_)->get();
BOOST_VARIANT_AUX_RETURN_VOID;
}
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(T& lhs_content, int) const
void internal_visit(T& lhs_content, int) const
{
// NOTE TO USER :
// Compile error here indicates one of variant's bounded types does
@@ -560,7 +543,6 @@ public: // internal visitor interfaces
// Hint: Are any of the bounded types const-qualified or references?
//
lhs_content = *static_cast< const T* >(rhs_storage_);
BOOST_VARIANT_AUX_RETURN_VOID;
}
};
@@ -588,26 +570,21 @@ public: // structors
public: // internal visitor interfaces
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(backup_holder<T>& lhs_content, long) const
void internal_visit(backup_holder<T>& lhs_content, long) const
{
lhs_content.get()
= ::boost::detail::variant::move(static_cast<backup_holder<T>* >(rhs_storage_)->get());
BOOST_VARIANT_AUX_RETURN_VOID;
}
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(const backup_holder<T>& lhs_content, long) const
void internal_visit(const backup_holder<T>& lhs_content, long) const
{
lhs_content.get()
= ::boost::detail::variant::move(static_cast<backup_holder<T>* >(rhs_storage_)->get());
BOOST_VARIANT_AUX_RETURN_VOID;
}
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(T& lhs_content, int) const
void internal_visit(T& lhs_content, int) const
{
// NOTE TO USER :
// Compile error here indicates one of variant's bounded types does
@@ -617,7 +594,6 @@ public: // internal visitor interfaces
// Hint: Are any of the bounded types const-qualified or references?
//
lhs_content = ::boost::detail::variant::move(*static_cast<T* >(rhs_storage_));
BOOST_VARIANT_AUX_RETURN_VOID;
}
};
@@ -864,15 +840,12 @@ private: // helpers, for visitor interface (below)
public: // visitor interface
template <typename LhsT>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(LhsT& lhs_content, int)
void internal_visit(LhsT& lhs_content, int)
{
typedef typename is_nothrow_move_constructible<LhsT>::type
nothrow_move;
backup_assign_impl( lhs_content, nothrow_move(), 1L);
BOOST_VARIANT_AUX_RETURN_VOID;
}
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
@@ -1017,7 +990,7 @@ struct less_comp
// * for wrappers (e.g., recursive_wrapper), the wrapper's held value.
// * for all other values, the value itself.
//
template <typename Visitor>
template <typename Visitor, bool MoveSemantics>
class invoke_visitor
{
private: // representation
@@ -1036,10 +1009,26 @@ public: // structors
{
}
#if !defined(BOOST_NO_VOID_RETURNS)
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<T>(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
template <typename T>
typename disable_if_c<MoveSemantics && is_same<T, T>::value, result_type>::type internal_visit(T&& operand, int)
{
return visitor_(operand);
}
#else
template <typename T>
result_type internal_visit(T& operand, int)
{
@@ -1052,81 +1041,44 @@ public: // internal visitor interfaces
{
return visitor_(operand);
}
# endif
# endif //BORLAND
#else // defined(BOOST_NO_VOID_RETURNS)
private: // helpers, for internal visitor interfaces (below)
template <typename T>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
visit_impl(T& operand, mpl::false_)
{
return visitor_(operand);
}
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
visit_impl(T& operand, mpl::true_)
{
visitor_(operand);
BOOST_VARIANT_AUX_RETURN_VOID;
}
public: // internal visitor interfaces
template <typename T>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
internal_visit(T& operand, int)
{
typedef typename is_same<result_type, void>::type
has_void_result_type;
return visit_impl(operand, has_void_result_type());
}
#endif // BOOST_NO_VOID_RETURNS) workaround
#endif //RVALUE REFERENCES
public: // internal visitor interfaces, cont.
template <typename T>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
internal_visit(boost::recursive_wrapper<T>& operand, long)
result_type internal_visit(boost::recursive_wrapper<T>& operand, long)
{
return internal_visit( operand.get(), 1L );
}
template <typename T>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
internal_visit(const boost::recursive_wrapper<T>& operand, long)
result_type internal_visit(const boost::recursive_wrapper<T>& operand, long)
{
return internal_visit( operand.get(), 1L );
}
template <typename T>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
internal_visit(boost::detail::reference_content<T>& operand, long)
result_type internal_visit(boost::detail::reference_content<T>& operand, long)
{
return internal_visit( operand.get(), 1L );
}
template <typename T>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
internal_visit(const boost::detail::reference_content<T>& operand, long)
result_type internal_visit(const boost::detail::reference_content<T>& operand, long)
{
return internal_visit( operand.get(), 1L );
}
template <typename T>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
internal_visit(boost::detail::variant::backup_holder<T>& operand, long)
result_type internal_visit(boost::detail::variant::backup_holder<T>& operand, long)
{
return internal_visit( operand.get(), 1L );
}
template <typename T>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
internal_visit(const boost::detail::variant::backup_holder<T>& operand, long)
result_type internal_visit(const boost::detail::variant::backup_holder<T>& operand, long)
{
return internal_visit( operand.get(), 1L );
}
@@ -1951,8 +1903,7 @@ private: // helpers, for modifiers (below)
public: // internal visitor interfaces
template <typename RhsT>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(const RhsT& rhs_content, int) const
void internal_visit(const RhsT& rhs_content, int) const
{
typedef typename has_nothrow_copy<RhsT>::type
nothrow_copy;
@@ -1967,8 +1918,6 @@ private: // helpers, for modifiers (below)
, nothrow_move_constructor()
, has_fallback_type_()
);
BOOST_VARIANT_AUX_RETURN_VOID;
}
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
@@ -2073,8 +2022,7 @@ private: // helpers, for modifiers (below)
public: // internal visitor interfaces
template <typename RhsT>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(RhsT& rhs_content, int) const
void internal_visit(RhsT& rhs_content, int) const
{
typedef typename is_nothrow_move_constructible<RhsT>::type
nothrow_move_constructor;
@@ -2089,8 +2037,6 @@ private: // helpers, for modifiers (below)
, nothrow_move_constructor()
, has_fallback_type_()
);
BOOST_VARIANT_AUX_RETURN_VOID;
}
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
@@ -2368,10 +2314,7 @@ public:
#endif// !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
template <typename Visitor, typename VoidPtrCV>
static
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(
typename Visitor::result_type
)
static typename Visitor::result_type
internal_apply_visitor_impl(
int internal_which
, int logical_which
@@ -2396,9 +2339,7 @@ public:
}
template <typename Visitor>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(
typename Visitor::result_type
)
typename Visitor::result_type
internal_apply_visitor(Visitor& visitor)
{
return internal_apply_visitor_impl(
@@ -2407,9 +2348,7 @@ public:
}
template <typename Visitor>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(
typename Visitor::result_type
)
typename Visitor::result_type
internal_apply_visitor(Visitor& visitor) const
{
return internal_apply_visitor_impl(
@@ -2419,23 +2358,45 @@ public:
public: // visitation support
#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
template <typename Visitor>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(
typename Visitor::result_type
)
apply_visitor(Visitor& visitor)
typename Visitor::result_type
apply_visitor(Visitor& visitor) &&
{
detail::variant::invoke_visitor<Visitor> invoker(visitor);
detail::variant::invoke_visitor<Visitor, true> invoker(visitor);
return this->internal_apply_visitor(invoker);
}
template <typename Visitor>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(
typename Visitor::result_type
)
apply_visitor(Visitor& visitor) const
typename Visitor::result_type
apply_visitor(Visitor& visitor) const&&
{
detail::variant::invoke_visitor<Visitor> invoker(visitor);
detail::variant::invoke_visitor<Visitor, true> invoker(visitor);
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
{
detail::variant::invoke_visitor<Visitor, false> invoker(visitor);
return this->internal_apply_visitor(invoker);
}
template <typename Visitor>
typename Visitor::result_type
apply_visitor(Visitor& visitor) const
#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
&
#endif
{
detail::variant::invoke_visitor<Visitor, false> invoker(visitor);
return this->internal_apply_visitor(invoker);
}
@@ -2452,16 +2413,20 @@ struct make_variant_over
private: // precondition assertions
BOOST_STATIC_ASSERT(( ::boost::mpl::is_sequence<Types>::value ));
typedef typename boost::mpl::insert_range<
boost::mpl::list<>
, boost::mpl::end< boost::mpl::list<> >::type
, Types
>::type copied_sequence_t;
public: // metafunction result
typedef variant<
detail::variant::over_sequence< Types >
detail::variant::over_sequence<copied_sequence_t>
> type;
};
///////////////////////////////////////////////////////////////////////////////
// function template swap
//

View File

@@ -4,7 +4,7 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) 2003 Eric Friedman, Itay Maman
// Copyright (c) 2013-2016 Antony Polukhin
// Copyright (c) 2013-2019 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at

View File

@@ -68,8 +68,6 @@ public: // static visitor interfaces
boost::throw_exception(bad_visit());
}
#if !defined(BOOST_NO_VOID_RETURNS)
public: // static visitor interfaces, cont.
result_type operator()(argument_fwd_type operand) const
@@ -77,33 +75,6 @@ public: // static visitor interfaces, cont.
return visitor_(operand);
}
#else // defined(BOOST_NO_VOID_RETURNS)
private: // helpers, for static visitor interfaces (below)
result_type execute_impl(argument_fwd_type operand, mpl::false_) const
{
return visitor_(operand);
}
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
execute_impl(argument_fwd_type operand, mpl::true_) const
{
visitor_(operand);
BOOST_VARIANT_AUX_RETURN_VOID;
}
public: // static visitor interfaces, cont.
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
operator()(argument_fwd_type operand) const
{
typedef typename is_void<result_type>::type has_void_result;
return execute_impl(operand, has_void_result());
}
#endif // BOOST_NO_VOID_RETURNS workaround
};
template <typename R, typename T>