stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/apply_visitor.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_APPLY_VISITOR_HPP
|
||||
#define BOOST_VARIANT_APPLY_VISITOR_HPP
|
||||
|
||||
#include <boost/variant/detail/apply_visitor_unary.hpp>
|
||||
#include <boost/variant/detail/apply_visitor_binary.hpp>
|
||||
#include <boost/variant/detail/apply_visitor_delayed.hpp>
|
||||
|
||||
#endif // BOOST_VARIANT_APPLY_VISITOR_HPP
|
||||
@@ -0,0 +1,41 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/bad_visit.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-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_BAD_VISIT_HPP
|
||||
#define BOOST_VARIANT_BAD_VISIT_HPP
|
||||
|
||||
#include <exception>
|
||||
|
||||
namespace boost {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// class bad_visit
|
||||
//
|
||||
// Exception thrown when a visitation attempt via apply_visitor fails due
|
||||
// to invalid visited subtype or contents.
|
||||
//
|
||||
struct bad_visit
|
||||
: std::exception
|
||||
{
|
||||
public: // std::exception interface
|
||||
|
||||
virtual const char * what() const BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
return "boost::bad_visit: "
|
||||
"failed visitation using boost::apply_visitor";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_BAD_VISIT_HPP
|
||||
@@ -0,0 +1,280 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/apply_visitor_binary.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-2003 Eric Friedman
|
||||
// Copyright (c) 2014 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_VARIANT_DETAIL_APPLY_VISITOR_BINARY_HPP
|
||||
#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
|
||||
|
||||
namespace boost {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// function template apply_visitor(visitor, visitable1, visitable2)
|
||||
//
|
||||
// Visits visitable1 and visitable2 such that their values (which we
|
||||
// shall call x and y, respectively) are used as arguments in the
|
||||
// expression visitor(x, y).
|
||||
//
|
||||
|
||||
namespace detail { namespace variant {
|
||||
|
||||
template <typename Visitor, typename Value1>
|
||||
class apply_visitor_binary_invoke
|
||||
{
|
||||
public: // visitor typedefs
|
||||
|
||||
typedef typename Visitor::result_type
|
||||
result_type;
|
||||
|
||||
private: // representation
|
||||
|
||||
Visitor& visitor_;
|
||||
Value1& value1_;
|
||||
|
||||
public: // structors
|
||||
|
||||
apply_visitor_binary_invoke(Visitor& visitor, Value1& value1) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
, value1_(value1)
|
||||
{
|
||||
}
|
||||
|
||||
public: // visitor interfaces
|
||||
|
||||
template <typename Value2>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
operator()(Value2& value2)
|
||||
{
|
||||
return visitor_(value1_, value2);
|
||||
}
|
||||
|
||||
private:
|
||||
apply_visitor_binary_invoke& operator=(const apply_visitor_binary_invoke&);
|
||||
};
|
||||
|
||||
template <typename Visitor, typename Visitable2>
|
||||
class apply_visitor_binary_unwrap
|
||||
{
|
||||
public: // visitor typedefs
|
||||
|
||||
typedef typename Visitor::result_type
|
||||
result_type;
|
||||
|
||||
private: // representation
|
||||
|
||||
Visitor& visitor_;
|
||||
Visitable2& visitable2_;
|
||||
|
||||
public: // structors
|
||||
|
||||
apply_visitor_binary_unwrap(Visitor& visitor, Visitable2& visitable2) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
, visitable2_(visitable2)
|
||||
{
|
||||
}
|
||||
|
||||
public: // visitor interfaces
|
||||
|
||||
template <typename Value1>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
operator()(Value1& value1)
|
||||
{
|
||||
apply_visitor_binary_invoke<
|
||||
Visitor
|
||||
, Value1
|
||||
> invoker(visitor_, value1);
|
||||
|
||||
return boost::apply_visitor(invoker, visitable2_);
|
||||
}
|
||||
|
||||
private:
|
||||
apply_visitor_binary_unwrap& operator=(const apply_visitor_binary_unwrap&);
|
||||
|
||||
};
|
||||
|
||||
}} // namespace detail::variant
|
||||
|
||||
//
|
||||
// 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
|
||||
|
||||
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
|
||||
)
|
||||
{
|
||||
::boost::detail::variant::apply_visitor_binary_unwrap<
|
||||
Visitor, Visitable2
|
||||
> unwrapper(visitor, visitable2);
|
||||
|
||||
return boost::apply_visitor(unwrapper, visitable1);
|
||||
}
|
||||
|
||||
#undef BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE
|
||||
|
||||
//
|
||||
// const-visitor version:
|
||||
//
|
||||
|
||||
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
|
||||
)
|
||||
{
|
||||
::boost::detail::variant::apply_visitor_binary_unwrap<
|
||||
const Visitor, Visitable2
|
||||
> unwrapper(visitor, visitable2);
|
||||
|
||||
return boost::apply_visitor(unwrapper, visitable1);
|
||||
}
|
||||
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// function template apply_visitor(visitor, visitable1, visitable2)
|
||||
//
|
||||
// C++14 part.
|
||||
//
|
||||
|
||||
namespace detail { namespace variant {
|
||||
|
||||
template <typename Visitor, typename Value1>
|
||||
class apply_visitor_binary_invoke_cpp14
|
||||
{
|
||||
Visitor& visitor_;
|
||||
Value1& value1_;
|
||||
|
||||
public: // structors
|
||||
|
||||
apply_visitor_binary_invoke_cpp14(Visitor& visitor, Value1& value1) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
, value1_(value1)
|
||||
{
|
||||
}
|
||||
|
||||
public: // visitor interfaces
|
||||
|
||||
template <typename Value2>
|
||||
decltype(auto) operator()(Value2& value2)
|
||||
{
|
||||
return visitor_(value1_, value2);
|
||||
}
|
||||
|
||||
private:
|
||||
apply_visitor_binary_invoke_cpp14& operator=(const apply_visitor_binary_invoke_cpp14&);
|
||||
};
|
||||
|
||||
template <typename Visitor, typename Visitable2>
|
||||
class apply_visitor_binary_unwrap_cpp14
|
||||
{
|
||||
Visitor& visitor_;
|
||||
Visitable2& visitable2_;
|
||||
|
||||
public: // structors
|
||||
|
||||
apply_visitor_binary_unwrap_cpp14(Visitor& visitor, Visitable2& visitable2) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
, visitable2_(visitable2)
|
||||
{
|
||||
}
|
||||
|
||||
public: // visitor interfaces
|
||||
|
||||
template <typename Value1>
|
||||
decltype(auto) operator()(Value1& value1)
|
||||
{
|
||||
apply_visitor_binary_invoke_cpp14<
|
||||
Visitor
|
||||
, Value1
|
||||
> invoker(visitor_, value1);
|
||||
|
||||
return boost::apply_visitor(invoker, visitable2_);
|
||||
}
|
||||
|
||||
private:
|
||||
apply_visitor_binary_unwrap_cpp14& operator=(const apply_visitor_binary_unwrap_cpp14&);
|
||||
};
|
||||
|
||||
}} // namespace detail::variant
|
||||
|
||||
template <typename Visitor, typename Visitable1, typename 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
|
||||
> unwrapper(visitor, visitable2);
|
||||
|
||||
return boost::apply_visitor(unwrapper, visitable1);
|
||||
}
|
||||
|
||||
template <typename Visitor, typename Visitable1, typename 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
|
||||
> unwrapper(visitor, visitable2);
|
||||
|
||||
return boost::apply_visitor(unwrapper, visitable1);
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_APPLY_VISITOR_BINARY_HPP
|
||||
@@ -0,0 +1,151 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/apply_visitor_delayed.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-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_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
|
||||
|
||||
|
||||
#include <boost/variant/detail/has_result_type.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// function template apply_visitor(visitor)
|
||||
//
|
||||
// Returns a function object, overloaded for unary and binary usage, that
|
||||
// visits its arguments using visitor (or a copy of visitor) via
|
||||
// * apply_visitor( visitor, [argument] )
|
||||
// under unary invocation, or
|
||||
// * apply_visitor( visitor, [argument1], [argument2] )
|
||||
// under binary invocation.
|
||||
//
|
||||
// NOTE: Unlike other apply_visitor forms, the visitor object must be
|
||||
// non-const; this prevents user from giving temporary, to disastrous
|
||||
// effect (i.e., returned function object would have dead reference).
|
||||
//
|
||||
|
||||
template <typename Visitor>
|
||||
class apply_visitor_delayed_t
|
||||
{
|
||||
public: // visitor typedefs
|
||||
|
||||
typedef typename Visitor::result_type
|
||||
result_type;
|
||||
|
||||
private: // representation
|
||||
|
||||
Visitor& visitor_;
|
||||
|
||||
public: // structors
|
||||
|
||||
explicit apply_visitor_delayed_t(Visitor& visitor) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
public: // N-ary visitor interface
|
||||
template <typename... Visitables>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
operator()(Visitables&... visitables) const
|
||||
{
|
||||
return apply_visitor(visitor_, visitables...);
|
||||
}
|
||||
|
||||
#else // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
public: // unary visitor interface
|
||||
|
||||
template <typename Visitable>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
|
||||
operator()(Visitable& visitable) const
|
||||
{
|
||||
return apply_visitor(visitor_, visitable);
|
||||
}
|
||||
|
||||
public: // binary visitor interface
|
||||
|
||||
template <typename Visitable1, typename Visitable2>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(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&);
|
||||
|
||||
};
|
||||
|
||||
template <typename Visitor>
|
||||
inline typename boost::enable_if<
|
||||
boost::detail::variant::has_result_type<Visitor>,
|
||||
apply_visitor_delayed_t<Visitor>
|
||||
>::type apply_visitor(Visitor& visitor)
|
||||
{
|
||||
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)
|
||||
|
||||
template <typename Visitor>
|
||||
class apply_visitor_delayed_cpp14_t
|
||||
{
|
||||
private: // representation
|
||||
Visitor& visitor_;
|
||||
|
||||
public: // structors
|
||||
|
||||
explicit apply_visitor_delayed_cpp14_t(Visitor& visitor) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
{
|
||||
}
|
||||
|
||||
public: // N-ary visitor interface
|
||||
template <typename... Visitables>
|
||||
decltype(auto) operator()(Visitables&... visitables) const
|
||||
{
|
||||
return apply_visitor(visitor_, visitables...);
|
||||
}
|
||||
|
||||
private:
|
||||
apply_visitor_delayed_cpp14_t& operator=(const apply_visitor_delayed_cpp14_t&);
|
||||
|
||||
};
|
||||
|
||||
template <typename Visitor>
|
||||
inline typename boost::disable_if<
|
||||
boost::detail::variant::has_result_type<Visitor>,
|
||||
apply_visitor_delayed_cpp14_t<Visitor>
|
||||
>::type apply_visitor(Visitor& visitor)
|
||||
{
|
||||
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)
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_APPLY_VISITOR_DELAYED_HPP
|
||||
@@ -0,0 +1,173 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/apply_visitor_unary.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-2003 Eric Friedman
|
||||
// Copyright (c) 2014 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_VARIANT_DETAIL_APPLY_VISITOR_UNARY_HPP
|
||||
#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
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
# include <boost/mpl/distance.hpp>
|
||||
# include <boost/mpl/advance.hpp>
|
||||
# include <boost/mpl/deref.hpp>
|
||||
# include <boost/mpl/size.hpp>
|
||||
# include <boost/utility/declval.hpp>
|
||||
# include <boost/core/enable_if.hpp>
|
||||
# include <boost/variant/detail/has_result_type.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// function template apply_visitor(visitor, visitable)
|
||||
//
|
||||
// Visits visitable with visitor.
|
||||
//
|
||||
|
||||
//
|
||||
// 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
|
||||
|
||||
template <typename Visitor, typename Visitable>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(Visitor)
|
||||
apply_visitor(Visitor& visitor, Visitable& visitable)
|
||||
{
|
||||
return visitable.apply_visitor(visitor);
|
||||
}
|
||||
|
||||
#undef BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE
|
||||
|
||||
//
|
||||
// const-visitor version:
|
||||
//
|
||||
|
||||
template <typename Visitor, typename Visitable>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
apply_visitor(const Visitor& visitor, Visitable& visitable)
|
||||
{
|
||||
return visitable.apply_visitor(visitor);
|
||||
}
|
||||
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
|
||||
// C++14
|
||||
namespace detail { namespace variant {
|
||||
|
||||
// This class serves only metaprogramming purposes. none of its methods must be called at runtime!
|
||||
template <class Visitor, class Variant>
|
||||
struct result_multideduce1 {
|
||||
typedef typename Variant::types types;
|
||||
typedef typename boost::mpl::begin<types>::type begin_it;
|
||||
typedef typename boost::mpl::advance<
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
return vis()( boost::declval< value_t& >() );
|
||||
}
|
||||
|
||||
static decltype(auto) deduce() {
|
||||
return deduce_impl(begin_it(), 0);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Visitor, class Variant>
|
||||
struct result_wrapper1
|
||||
{
|
||||
typedef decltype(result_multideduce1<Visitor, Variant>::deduce()) result_type;
|
||||
|
||||
Visitor& visitor_;
|
||||
explicit result_wrapper1(Visitor& visitor) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
{}
|
||||
|
||||
template <class T>
|
||||
result_type operator()(T& val) const {
|
||||
return visitor_(val);
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail::variant
|
||||
|
||||
template <typename Visitor, typename 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);
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_APPLY_VISITOR_UNARY_HPP
|
||||
@@ -0,0 +1,95 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/backup_holder.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_BACKUP_HOLDER_HPP
|
||||
#define BOOST_VARIANT_DETAIL_BACKUP_HOLDER_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
|
||||
template <typename T>
|
||||
class backup_holder
|
||||
{
|
||||
private: // representation
|
||||
|
||||
T* backup_;
|
||||
|
||||
public: // structors
|
||||
|
||||
~backup_holder() BOOST_NOEXCEPT
|
||||
{
|
||||
delete backup_;
|
||||
}
|
||||
|
||||
explicit backup_holder(T* backup) BOOST_NOEXCEPT
|
||||
: backup_(backup)
|
||||
{
|
||||
}
|
||||
|
||||
backup_holder(const backup_holder&);
|
||||
|
||||
public: // modifiers
|
||||
|
||||
backup_holder& operator=(const backup_holder& rhs)
|
||||
{
|
||||
*backup_ = rhs.get();
|
||||
return *this;
|
||||
}
|
||||
|
||||
backup_holder& operator=(const T& rhs)
|
||||
{
|
||||
*backup_ = rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(backup_holder& rhs) BOOST_NOEXCEPT
|
||||
{
|
||||
T* tmp = rhs.backup_;
|
||||
rhs.backup_ = this->backup_;
|
||||
this->backup_ = tmp;
|
||||
}
|
||||
|
||||
public: // queries
|
||||
|
||||
T& get() BOOST_NOEXCEPT
|
||||
{
|
||||
return *backup_;
|
||||
}
|
||||
|
||||
const T& get() const BOOST_NOEXCEPT
|
||||
{
|
||||
return *backup_;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
backup_holder<T>::backup_holder(const backup_holder&)
|
||||
: backup_(0)
|
||||
{
|
||||
// not intended for copy, but do not want to prohibit syntactically
|
||||
BOOST_ASSERT(false);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void swap(backup_holder<T>& lhs, backup_holder<T>& rhs) BOOST_NOEXCEPT
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_BACKUP_HOLDER_HPP
|
||||
@@ -0,0 +1,42 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/cast_storage.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_CAST_STORAGE_HPP
|
||||
#define BOOST_VARIANT_DETAIL_CAST_STORAGE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) function template cast_storage
|
||||
//
|
||||
// Casts the given storage to the specified type, but with qualification.
|
||||
//
|
||||
|
||||
template <typename T>
|
||||
inline T& cast_storage(void* storage)
|
||||
{
|
||||
return *static_cast<T*>(storage);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const T& cast_storage(const void* storage)
|
||||
{
|
||||
return *static_cast<const T*>(storage);
|
||||
}
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_CAST_STORAGE_HPP
|
||||
@@ -0,0 +1,19 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/config.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman
|
||||
// Copyright (c) 2016 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_VARIANT_DETAIL_CONFIG_HPP
|
||||
#define BOOST_VARIANT_DETAIL_CONFIG_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_CONFIG_HPP
|
||||
@@ -0,0 +1,63 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/element_index.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2014-2015 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_VARIANT_DETAIL_ELEMENT_INDEX_HPP
|
||||
#define BOOST_VARIANT_DETAIL_ELEMENT_INDEX_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/variant/recursive_wrapper_fwd.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/mpl/find_if.hpp>
|
||||
|
||||
namespace boost { namespace detail { namespace variant {
|
||||
|
||||
template <class VariantElement, class T>
|
||||
struct variant_element_functor :
|
||||
boost::mpl::or_<
|
||||
boost::is_same<VariantElement, T>,
|
||||
boost::is_same<VariantElement, boost::recursive_wrapper<T> >,
|
||||
boost::is_same<VariantElement, T& >
|
||||
>
|
||||
{};
|
||||
|
||||
template <class Types, class T>
|
||||
struct element_iterator_impl :
|
||||
boost::mpl::find_if<
|
||||
Types,
|
||||
boost::mpl::or_<
|
||||
variant_element_functor<boost::mpl::_1, T>,
|
||||
variant_element_functor<boost::mpl::_1, typename boost::remove_cv<T>::type >
|
||||
>
|
||||
>
|
||||
{};
|
||||
|
||||
template <class Variant, class T>
|
||||
struct element_iterator :
|
||||
element_iterator_impl< typename Variant::types, typename boost::remove_reference<T>::type >
|
||||
{};
|
||||
|
||||
template <class Variant, class T>
|
||||
struct holds_element :
|
||||
boost::mpl::not_<
|
||||
boost::is_same<
|
||||
typename boost::mpl::end<typename Variant::types>::type,
|
||||
typename element_iterator<Variant, T>::type
|
||||
>
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
}}} // namespace boost::detail::variant
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_ELEMENT_INDEX_HPP
|
||||
@@ -0,0 +1,133 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/enable_recursive.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_ENABLE_RECURSIVE_HPP
|
||||
#define BOOST_VARIANT_DETAIL_ENABLE_RECURSIVE_HPP
|
||||
|
||||
#include <boost/variant/detail/enable_recursive_fwd.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
#if !defined(BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT)
|
||||
# include <boost/mpl/apply.hpp>
|
||||
# include <boost/mpl/eval_if.hpp>
|
||||
# include <boost/mpl/lambda.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/variant/detail/substitute.hpp>
|
||||
#include <boost/mpl/aux_/config/ctps.hpp>
|
||||
#include <boost/mpl/bool_fwd.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/variant/recursive_wrapper.hpp>
|
||||
|
||||
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
|
||||
//
|
||||
// See boost/variant/detail/enable_recursive_fwd.hpp for more information.
|
||||
//
|
||||
|
||||
|
||||
template <typename T, typename RecursiveVariant, typename NoWrapper>
|
||||
struct enable_recursive
|
||||
: BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL(
|
||||
T, RecursiveVariant, ::boost::recursive_variant_
|
||||
)
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename RecursiveVariant>
|
||||
struct enable_recursive< T,RecursiveVariant,mpl::false_ >
|
||||
{
|
||||
private: // helpers, for metafunction result (below)
|
||||
|
||||
typedef typename BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL(
|
||||
T, RecursiveVariant, ::boost::recursive_variant_
|
||||
)::type t_;
|
||||
|
||||
public: // metafunction result
|
||||
|
||||
// [Wrap with recursive_wrapper only if rebind really changed something:]
|
||||
typedef typename mpl::if_<
|
||||
mpl::or_<
|
||||
is_same< t_,T >
|
||||
, is_reference<t_>
|
||||
, is_pointer<t_>
|
||||
>
|
||||
, t_
|
||||
, boost::recursive_wrapper<t_>
|
||||
>::type type;
|
||||
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction class quoted_enable_recursive
|
||||
//
|
||||
// Same behavior as enable_recursive metafunction (see above).
|
||||
//
|
||||
template <typename RecursiveVariant, typename NoWrapper>
|
||||
struct quoted_enable_recursive
|
||||
{
|
||||
template <typename T>
|
||||
struct apply
|
||||
: enable_recursive<T, RecursiveVariant, NoWrapper>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_ENABLE_RECURSIVE_HPP
|
||||
@@ -0,0 +1,87 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/enable_recursive_fwd.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_ENABLE_RECURSIVE_FWD_HPP
|
||||
#define BOOST_VARIANT_DETAIL_ENABLE_RECURSIVE_FWD_HPP
|
||||
|
||||
#include <boost/mpl/aux_/config/ctps.hpp>
|
||||
|
||||
#include <boost/mpl/bool_fwd.hpp>
|
||||
|
||||
# include <boost/mpl/bool.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) tag recursive_flag
|
||||
//
|
||||
// Signifies that the variant should perform recursive substituion.
|
||||
//
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct recursive_flag
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction is_recursive_flag
|
||||
//
|
||||
// Signifies that the variant should perform recursive substituion.
|
||||
//
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct is_recursive_flag
|
||||
: mpl::false_
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_recursive_flag< recursive_flag<T> >
|
||||
: mpl::true_
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction enable_recursive
|
||||
//
|
||||
// Attempts recursive_variant_ tag substitution, wrapping with
|
||||
// boost::recursive_wrapper if substituion occurs w/ non-indirect result
|
||||
// (i.e., not a reference or pointer) *and* NoWrapper is false_.
|
||||
//
|
||||
template <
|
||||
typename T
|
||||
, typename RecursiveVariant
|
||||
, typename NoWrapper = mpl::false_
|
||||
>
|
||||
struct enable_recursive;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction class quoted_enable_recursive
|
||||
//
|
||||
// Same behavior as enable_recursive metafunction (see above).
|
||||
//
|
||||
template <
|
||||
typename RecursiveVariant
|
||||
, typename NoWrapper = mpl::false_
|
||||
>
|
||||
struct quoted_enable_recursive;
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_ENABLE_RECURSIVE_FWD_HPP
|
||||
@@ -0,0 +1,64 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/forced_return.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman
|
||||
// Copyright (c) 2015-2016 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_VARIANT_DETAIL_FORCED_RETURN_HPP
|
||||
#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
|
||||
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable : 4702 ) // unreachable code
|
||||
#endif
|
||||
|
||||
namespace boost { namespace detail { namespace variant {
|
||||
|
||||
BOOST_NORETURN inline void forced_return_no_return() { // fixes `must return a value` warnings
|
||||
using namespace std;
|
||||
abort(); // some implementations have no std::abort
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) function template forced_return
|
||||
//
|
||||
// Logical error to permit invocation at runtime, but (artificially) satisfies
|
||||
// compile-time requirement of returning a result value.
|
||||
//
|
||||
template <typename T>
|
||||
BOOST_NORETURN inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T)
|
||||
forced_return()
|
||||
{
|
||||
// logical error: should never be here! (see above)
|
||||
BOOST_ASSERT(false);
|
||||
|
||||
forced_return_no_return();
|
||||
|
||||
#ifdef BOOST_NO_NORETURN
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T) (*dummy)() = 0;
|
||||
return dummy();
|
||||
#endif
|
||||
}
|
||||
|
||||
}}} // namespace boost::detail::variant
|
||||
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning( pop )
|
||||
#endif
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_FORCED_RETURN_HPP
|
||||
@@ -0,0 +1,88 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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
|
||||
@@ -0,0 +1,37 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/has_result_type.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2014-2015 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_VARIANT_DETAIL_HAS_RESULT_TYPE_HPP
|
||||
#define BOOST_VARIANT_DETAIL_HAS_RESULT_TYPE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace detail { namespace variant {
|
||||
|
||||
template <typename T >
|
||||
struct has_result_type {
|
||||
private:
|
||||
typedef char yes;
|
||||
typedef struct { char array[2]; } no;
|
||||
|
||||
template<typename C> static yes test(typename boost::remove_reference<typename C::result_type>::type*);
|
||||
template<typename C> static no test(...);
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, value = sizeof(test<T>(0)) == sizeof(yes));
|
||||
};
|
||||
|
||||
}}} // namespace boost::detail::variant
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_HAS_RESULT_TYPE_HPP
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/hash_variant.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2011
|
||||
// Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
#ifndef BOOST_HASH_VARIANT_FUNCTION_HPP
|
||||
#define BOOST_HASH_VARIANT_FUNCTION_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
#include <boost/variant/apply_visitor.hpp>
|
||||
#include <boost/functional/hash_fwd.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail { namespace variant {
|
||||
struct variant_hasher: public boost::static_visitor<std::size_t> {
|
||||
template <class T>
|
||||
std::size_t operator()(T const& val) const {
|
||||
boost::hash<T> hasher;
|
||||
return hasher(val);
|
||||
}
|
||||
};
|
||||
}}
|
||||
|
||||
template < BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
std::size_t hash_value(variant< BOOST_VARIANT_ENUM_PARAMS(T) > const& val) {
|
||||
std::size_t seed = boost::apply_visitor(detail::variant::variant_hasher(), val);
|
||||
hash_combine(seed, val.which());
|
||||
return seed;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/initializer.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-2003
|
||||
// Eric Friedman, Itay Maman
|
||||
//
|
||||
// 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_INITIALIZER_HPP
|
||||
#define BOOST_VARIANT_DETAIL_INITIALIZER_HPP
|
||||
|
||||
#include <new> // for placement new
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/call_traits.hpp>
|
||||
#include <boost/detail/reference_content.hpp>
|
||||
#include <boost/variant/recursive_wrapper_fwd.hpp>
|
||||
#include <boost/variant/detail/move.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
# include <boost/mpl/aux_/value_wknd.hpp>
|
||||
# include <boost/mpl/int.hpp>
|
||||
# include <boost/mpl/iter_fold.hpp>
|
||||
# include <boost/mpl/next.hpp>
|
||||
# include <boost/mpl/deref.hpp>
|
||||
# include <boost/mpl/pair.hpp>
|
||||
# include <boost/mpl/protect.hpp>
|
||||
#else
|
||||
# include <boost/variant/variant_fwd.hpp>
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
# include <boost/preprocessor/enum.hpp>
|
||||
# include <boost/preprocessor/repeat.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) support to simulate standard overload resolution rules
|
||||
//
|
||||
// The below initializers allows variant to follow standard overload
|
||||
// resolution rules over the specified set of bounded types.
|
||||
//
|
||||
// On compilers where using declarations in class templates can correctly
|
||||
// avoid name hiding, use an optimal solution based on the variant's typelist.
|
||||
//
|
||||
// Otherwise, use a preprocessor workaround based on knowledge of the fixed
|
||||
// size of the variant's psuedo-variadic template parameter list.
|
||||
//
|
||||
|
||||
#if !defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
|
||||
// (detail) quoted metafunction make_initializer_node
|
||||
//
|
||||
// Exposes a pair whose first type is a node in the initializer hierarchy.
|
||||
//
|
||||
struct make_initializer_node
|
||||
{
|
||||
template <typename BaseIndexPair, typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
private: // helpers, for metafunction result (below)
|
||||
|
||||
typedef typename BaseIndexPair::first
|
||||
base;
|
||||
typedef typename BaseIndexPair::second
|
||||
index;
|
||||
|
||||
class initializer_node
|
||||
: public base
|
||||
{
|
||||
private: // helpers, for static functions (below)
|
||||
|
||||
typedef typename mpl::deref<Iterator>::type
|
||||
recursive_enabled_T;
|
||||
typedef typename unwrap_recursive<recursive_enabled_T>::type
|
||||
public_T;
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
typedef boost::is_reference<public_T>
|
||||
is_reference_content_t;
|
||||
|
||||
typedef typename boost::mpl::if_<is_reference_content_t, public_T, const public_T& >::type
|
||||
param_T;
|
||||
|
||||
template <class T> struct disable_overload{};
|
||||
|
||||
typedef typename boost::mpl::if_<is_reference_content_t, disable_overload<public_T>, public_T&& >::type
|
||||
param2_T;
|
||||
#else
|
||||
typedef typename call_traits<public_T>::param_type
|
||||
param_T;
|
||||
#endif
|
||||
|
||||
public: // static functions
|
||||
|
||||
using base::initialize;
|
||||
|
||||
static int initialize(void* dest, param_T operand)
|
||||
{
|
||||
typedef typename boost::detail::make_reference_content<
|
||||
recursive_enabled_T
|
||||
>::type internal_T;
|
||||
|
||||
new(dest) internal_T(operand);
|
||||
return BOOST_MPL_AUX_VALUE_WKND(index)::value; // which
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
static int initialize(void* dest, param2_T operand)
|
||||
{
|
||||
// This assert must newer trigger, because all the reference contents are
|
||||
// handled by the initilize(void* dest, param_T operand) function above
|
||||
BOOST_ASSERT(!is_reference_content_t::value);
|
||||
|
||||
typedef typename boost::mpl::if_<is_reference_content_t, param2_T, recursive_enabled_T>::type value_T;
|
||||
new(dest) value_T( boost::detail::variant::move(operand) );
|
||||
return BOOST_MPL_AUX_VALUE_WKND(index)::value; // which
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
friend class initializer_node;
|
||||
|
||||
public: // metafunction result
|
||||
|
||||
typedef mpl::pair<
|
||||
initializer_node
|
||||
, typename mpl::next< index >::type
|
||||
> type;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
// (detail) class initializer_root
|
||||
//
|
||||
// Every level of the initializer hierarchy must expose the name
|
||||
// "initialize," so initializer_root provides a dummy function:
|
||||
//
|
||||
class initializer_root
|
||||
{
|
||||
public: // static functions
|
||||
|
||||
static void initialize();
|
||||
|
||||
};
|
||||
|
||||
#else // defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
|
||||
// Obsolete. Remove.
|
||||
#define BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_PARAMS \
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename recursive_enabled_T) \
|
||||
/**/
|
||||
|
||||
// Obsolete. Remove.
|
||||
#define BOOST_VARIANT_AUX_PP_INITIALIZER_DEFINE_PARAM_T(N) \
|
||||
typedef typename unwrap_recursive< \
|
||||
BOOST_PP_CAT(recursive_enabled_T,N) \
|
||||
>::type BOOST_PP_CAT(public_T,N); \
|
||||
typedef typename call_traits< \
|
||||
BOOST_PP_CAT(public_T,N) \
|
||||
>::param_type BOOST_PP_CAT(param_T,N); \
|
||||
/**/
|
||||
|
||||
template < BOOST_VARIANT_ENUM_PARAMS(typename recursive_enabled_T) >
|
||||
struct preprocessor_list_initializer
|
||||
{
|
||||
public: // static functions
|
||||
|
||||
#define BOOST_VARIANT_AUX_PP_INITIALIZE_FUNCTION(z,N,_) \
|
||||
typedef typename unwrap_recursive< \
|
||||
BOOST_PP_CAT(recursive_enabled_T,N) \
|
||||
>::type BOOST_PP_CAT(public_T,N); \
|
||||
typedef typename call_traits< \
|
||||
BOOST_PP_CAT(public_T,N) \
|
||||
>::param_type BOOST_PP_CAT(param_T,N); \
|
||||
static int initialize( \
|
||||
void* dest \
|
||||
, BOOST_PP_CAT(param_T,N) operand \
|
||||
) \
|
||||
{ \
|
||||
typedef typename boost::detail::make_reference_content< \
|
||||
BOOST_PP_CAT(recursive_enabled_T,N) \
|
||||
>::type internal_T; \
|
||||
\
|
||||
new(dest) internal_T(operand); \
|
||||
return (N); /*which*/ \
|
||||
} \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_VARIANT_LIMIT_TYPES
|
||||
, BOOST_VARIANT_AUX_PP_INITIALIZE_FUNCTION
|
||||
, _
|
||||
)
|
||||
|
||||
#undef BOOST_VARIANT_AUX_PP_INITIALIZE_FUNCTION
|
||||
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE workaround
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_AUX_INITIALIZER_T
|
||||
//
|
||||
// Given both the variant's typelist and a basename for forming the list of
|
||||
// bounded types (i.e., T becomes T1, T2, etc.), exposes the initializer
|
||||
// most appropriate to the current compiler.
|
||||
//
|
||||
|
||||
#if !defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
|
||||
#define BOOST_VARIANT_AUX_INITIALIZER_T( mpl_seq, typename_base ) \
|
||||
::boost::mpl::iter_fold< \
|
||||
mpl_seq \
|
||||
, ::boost::mpl::pair< \
|
||||
::boost::detail::variant::initializer_root \
|
||||
, ::boost::mpl::int_<0> \
|
||||
> \
|
||||
, ::boost::mpl::protect< \
|
||||
::boost::detail::variant::make_initializer_node \
|
||||
> \
|
||||
>::type::first \
|
||||
/**/
|
||||
|
||||
#else // defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
|
||||
// Obsolete. Remove.
|
||||
#define BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_ARGS(typename_base) \
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename_base) \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_AUX_INITIALIZER_T( mpl_seq, typename_base ) \
|
||||
::boost::detail::variant::preprocessor_list_initializer< \
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename_base) \
|
||||
> \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE workaround
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_INITIALIZER_HPP
|
||||
@@ -0,0 +1,73 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/make_variant_list.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-2003 Eric Friedman, Itay Maman
|
||||
// Copyright (c) 2013 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_VARIANT_DETAIL_MAKE_VARIANT_LIST_HPP
|
||||
#define BOOST_VARIANT_DETAIL_MAKE_VARIANT_LIST_HPP
|
||||
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
#include <boost/mpl/list.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/enum.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction make_variant_list
|
||||
//
|
||||
// Provides a MPL-compatible sequence with the specified non-void types
|
||||
// as arguments.
|
||||
//
|
||||
// Rationale: see class template convert_void (variant_fwd.hpp) and using-
|
||||
// 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
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_MAKE_VARIANT_LIST_HPP
|
||||
@@ -0,0 +1,53 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/move.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-2003 Eric Friedman
|
||||
// Copyright (c) 2002 by Andrei Alexandrescu
|
||||
// Copyright (c) 2013-2014 Antony Polukhin
|
||||
//
|
||||
// Use, modification and distribution are subject to 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)
|
||||
//
|
||||
// This file derivative of MoJO. Much thanks to Andrei for his initial work.
|
||||
// See <http://www.cuj.com/experts/2102/alexandr.htm> for information on MOJO.
|
||||
// Re-issued here under the Boost Software License, with permission of the original
|
||||
// author (Andrei Alexandrescu).
|
||||
|
||||
|
||||
#ifndef BOOST_VARIANT_DETAIL_MOVE_HPP
|
||||
#define BOOST_VARIANT_DETAIL_MOVE_HPP
|
||||
|
||||
#include <iterator> // for iterator_traits
|
||||
#include <new> // for placement new
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/move/adl_move_swap.hpp>
|
||||
|
||||
namespace boost { namespace detail { namespace variant {
|
||||
|
||||
using boost::move;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// function template move_swap
|
||||
//
|
||||
// Swaps using Koenig lookup but falls back to move-swap for primitive
|
||||
// types and on non-conforming compilers.
|
||||
//
|
||||
|
||||
template <typename T>
|
||||
inline void move_swap(T& lhs, T& rhs)
|
||||
{
|
||||
::boost::adl_move_swap(lhs, rhs);
|
||||
}
|
||||
|
||||
}}} // namespace boost::detail::variant
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_MOVE_HPP
|
||||
|
||||
|
||||
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
// Boost.Varaint
|
||||
// Contains multivisitors that are implemented via variadic templates and std::tuple
|
||||
//
|
||||
// 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_CPP11_BASED_HPP
|
||||
#define BOOST_VARIANT_DETAIL_MULTIVISITORS_CPP11_BASED_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/variant/detail/apply_visitor_unary.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp> // for BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
|
||||
#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 {
|
||||
|
||||
namespace detail { namespace variant {
|
||||
|
||||
// Implementing some of the C++14 features in C++11
|
||||
template <std::size_t... I> class index_sequence {};
|
||||
|
||||
template <std::size_t N, std::size_t... I>
|
||||
struct make_index_sequence
|
||||
: make_index_sequence<N-1, N-1, I...>
|
||||
{};
|
||||
template <std::size_t... I>
|
||||
struct make_index_sequence<0, I...>
|
||||
: index_sequence<I...>
|
||||
{};
|
||||
|
||||
template <class... Types>
|
||||
std::tuple<Types&...> forward_as_tuple_simple(Types&... args) BOOST_NOEXCEPT
|
||||
{
|
||||
return std::tuple<Types&...>(args...);
|
||||
}
|
||||
|
||||
// Implementing some of the helper tuple methods
|
||||
template <std::size_t... I, typename Tuple>
|
||||
std::tuple<typename std::tuple_element<I + 1, Tuple>::type...>
|
||||
tuple_tail_impl(const Tuple& tpl, index_sequence<I...>)
|
||||
{
|
||||
return std::tuple<
|
||||
typename std::tuple_element<I + 1, Tuple>::type...
|
||||
> (std::get<I + 1>(tpl)...);
|
||||
}
|
||||
|
||||
template <typename Head, typename... Tail>
|
||||
std::tuple<Tail...> tuple_tail(const std::tuple<Head, Tail...>& tpl)
|
||||
{
|
||||
return tuple_tail_impl(tpl, make_index_sequence<sizeof...(Tail)>());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Forward declaration
|
||||
template <typename Visitor, typename Visitables, typename... Values>
|
||||
class one_by_one_visitor_and_value_referer;
|
||||
|
||||
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
|
||||
)
|
||||
{
|
||||
return one_by_one_visitor_and_value_referer<Visitor, Visitables, Values... > (
|
||||
visitor, visitables, values
|
||||
);
|
||||
}
|
||||
|
||||
template <typename Visitor, typename Visitables, typename... Values>
|
||||
class one_by_one_visitor_and_value_referer
|
||||
{
|
||||
Visitor& visitor_;
|
||||
std::tuple<Values&...> values_;
|
||||
Visitables visitables_;
|
||||
|
||||
public: // structors
|
||||
one_by_one_visitor_and_value_referer(
|
||||
Visitor& visitor, Visitables visitables, std::tuple<Values&...> values
|
||||
) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
, values_(values)
|
||||
, visitables_(visitables)
|
||||
{}
|
||||
|
||||
public: // visitor interfaces
|
||||
typedef typename Visitor::result_type result_type;
|
||||
|
||||
template <typename Value>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(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::get<0>(visitables_) // getting Head element
|
||||
);
|
||||
}
|
||||
|
||||
private:
|
||||
one_by_one_visitor_and_value_referer& operator=(const one_by_one_visitor_and_value_referer&);
|
||||
};
|
||||
|
||||
template <typename Visitor, typename... Values>
|
||||
class one_by_one_visitor_and_value_referer<Visitor, std::tuple<>, Values...>
|
||||
{
|
||||
Visitor& visitor_;
|
||||
std::tuple<Values&...> values_;
|
||||
|
||||
public:
|
||||
one_by_one_visitor_and_value_referer(
|
||||
Visitor& visitor, std::tuple<> /*visitables*/, std::tuple<Values&...> values
|
||||
) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
, values_(values)
|
||||
{}
|
||||
|
||||
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)...);
|
||||
}
|
||||
|
||||
template <typename Value>
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type) operator()(Value& value) const
|
||||
{
|
||||
return do_call(
|
||||
std::tuple_cat(values_, std::tuple<Value&>(value)),
|
||||
make_index_sequence<sizeof...(Values) + 1>()
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
}} // 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)
|
||||
{
|
||||
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::tuple<>()
|
||||
),
|
||||
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)
|
||||
{
|
||||
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::tuple<>()
|
||||
),
|
||||
v1
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_MULTIVISITORS_CPP11_BASED_HPP
|
||||
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
// Boost.Varaint
|
||||
// Contains multivisitors that are implemented via variadic templates, std::tuple
|
||||
// and decltype(auto)
|
||||
//
|
||||
// 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_CPP14_BASED_HPP
|
||||
#define BOOST_VARIANT_DETAIL_MULTIVISITORS_CPP14_BASED_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/variant/detail/multivisitors_cpp14_based.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail { namespace variant {
|
||||
|
||||
// Forward declaration
|
||||
template <typename Visitor, typename Visitables, typename... Values>
|
||||
class one_by_one_visitor_and_value_referer_cpp14;
|
||||
|
||||
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
|
||||
)
|
||||
{
|
||||
return one_by_one_visitor_and_value_referer_cpp14<Visitor, Visitables, Values... > (
|
||||
visitor, visitables, values
|
||||
);
|
||||
}
|
||||
|
||||
template <typename Visitor, typename Visitables, typename... Values>
|
||||
class one_by_one_visitor_and_value_referer_cpp14
|
||||
{
|
||||
Visitor& visitor_;
|
||||
std::tuple<Values&...> values_;
|
||||
Visitables visitables_;
|
||||
|
||||
public: // structors
|
||||
one_by_one_visitor_and_value_referer_cpp14(
|
||||
Visitor& visitor, Visitables visitables, std::tuple<Values&...> values
|
||||
) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
, values_(values)
|
||||
, visitables_(visitables)
|
||||
{}
|
||||
|
||||
public: // visitor interfaces
|
||||
template <typename Value>
|
||||
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::get<0>(visitables_) // getting Head element
|
||||
);
|
||||
}
|
||||
|
||||
private:
|
||||
one_by_one_visitor_and_value_referer_cpp14& operator=(const one_by_one_visitor_and_value_referer_cpp14&);
|
||||
};
|
||||
|
||||
template <typename Visitor, typename... Values>
|
||||
class one_by_one_visitor_and_value_referer_cpp14<Visitor, std::tuple<>, Values...>
|
||||
{
|
||||
Visitor& visitor_;
|
||||
std::tuple<Values&...> values_;
|
||||
|
||||
public:
|
||||
one_by_one_visitor_and_value_referer_cpp14(
|
||||
Visitor& visitor, std::tuple<> /*visitables*/, std::tuple<Values&...> values
|
||||
) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
, values_(values)
|
||||
{}
|
||||
|
||||
template <class Tuple, std::size_t... I>
|
||||
decltype(auto) do_call(Tuple t, index_sequence<I...>) const {
|
||||
return visitor_(std::get<I>(t)...);
|
||||
}
|
||||
|
||||
template <typename Value>
|
||||
decltype(auto) operator()(Value& value) const
|
||||
{
|
||||
return do_call(
|
||||
std::tuple_cat(values_, std::tuple<Value&>(value)),
|
||||
make_index_sequence<sizeof...(Values) + 1>()
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
}} // 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,
|
||||
typename boost::disable_if<
|
||||
boost::detail::variant::has_result_type<Visitor>
|
||||
>::type* = 0)
|
||||
{
|
||||
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::tuple<>()
|
||||
),
|
||||
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,
|
||||
typename boost::disable_if<
|
||||
boost::detail::variant::has_result_type<Visitor>
|
||||
>::type* = 0)
|
||||
{
|
||||
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::tuple<>()
|
||||
),
|
||||
v1
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_MULTIVISITORS_CPP14_BASED_HPP
|
||||
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
// 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)> \
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(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_VARIANT_AUX_GENERIC_RESULT_TYPE(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
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/over_sequence.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003
|
||||
// Eric Friedman
|
||||
//
|
||||
// Portions Copyright (C) 2002 David Abrahams
|
||||
//
|
||||
// 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_OVER_SEQUENCE_HPP
|
||||
#define BOOST_VARIANT_DETAIL_OVER_SEQUENCE_HPP
|
||||
|
||||
#include <boost/mpl/aux_/config/ctps.hpp>
|
||||
|
||||
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) class over_sequence
|
||||
//
|
||||
// Wrapper used to indicate bounded types for variant are from type sequence.
|
||||
//
|
||||
template <typename Types>
|
||||
struct over_sequence
|
||||
{
|
||||
typedef Types type;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction is_over_sequence (modeled on code by David Abrahams)
|
||||
//
|
||||
// Indicates whether the specified type is of form over_sequence<...> or not.
|
||||
//
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct is_over_sequence
|
||||
: mpl::false_
|
||||
{
|
||||
};
|
||||
|
||||
template <typename Types>
|
||||
struct is_over_sequence< over_sequence<Types> >
|
||||
: mpl::true_
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_OVER_SEQUENCE_HPP
|
||||
@@ -0,0 +1,253 @@
|
||||
|
||||
#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.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// 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_SUBSTITUTE_HPP
|
||||
#define BOOST_VARIANT_DETAIL_SUBSTITUTE_HPP
|
||||
|
||||
#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/mpl/aux_/lambda_arity_param.hpp>
|
||||
#include <boost/mpl/aux_/preprocessor/params.hpp>
|
||||
#include <boost/mpl/aux_/preprocessor/repeat.hpp>
|
||||
#include <boost/mpl/int_fwd.hpp>
|
||||
#include <boost/mpl/limits/arity.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/empty.hpp>
|
||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
#include <boost/preprocessor/iterate.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
|
||||
#if !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction substitute
|
||||
//
|
||||
// Substitutes one type for another in the given type expression.
|
||||
//
|
||||
|
||||
//
|
||||
// primary template
|
||||
//
|
||||
template <
|
||||
typename T, typename Dest, typename Source
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(
|
||||
typename Arity /* = ... (see substitute_fwd.hpp) */
|
||||
)
|
||||
>
|
||||
struct substitute
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
//
|
||||
// tag substitution specializations
|
||||
//
|
||||
|
||||
#define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(CV_) \
|
||||
template <typename Dest, typename Source> \
|
||||
struct substitute< \
|
||||
CV_ Source \
|
||||
, Dest \
|
||||
, Source \
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>) \
|
||||
> \
|
||||
{ \
|
||||
typedef CV_ Dest type; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG( BOOST_PP_EMPTY() )
|
||||
BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(const)
|
||||
BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(volatile)
|
||||
BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG(const volatile)
|
||||
|
||||
#undef BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_SUBSTITUTE_TAG
|
||||
|
||||
//
|
||||
// pointer specializations
|
||||
//
|
||||
#define BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(CV_) \
|
||||
template <typename T, typename Dest, typename Source> \
|
||||
struct substitute< \
|
||||
T * CV_ \
|
||||
, Dest \
|
||||
, Source \
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>) \
|
||||
> \
|
||||
{ \
|
||||
typedef typename substitute< \
|
||||
T, Dest, Source \
|
||||
>::type * CV_ type; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER( BOOST_PP_EMPTY() )
|
||||
BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(const)
|
||||
BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(volatile)
|
||||
BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER(const volatile)
|
||||
|
||||
#undef BOOST_VARIANT_AUX_ENABLE_RECURSIVE_IMPL_HANDLE_POINTER
|
||||
|
||||
//
|
||||
// reference specializations
|
||||
//
|
||||
template <typename T, typename Dest, typename Source>
|
||||
struct substitute<
|
||||
T&
|
||||
, Dest
|
||||
, Source
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(mpl::int_<-1>)
|
||||
>
|
||||
{
|
||||
typedef typename substitute<
|
||||
T, Dest, Source
|
||||
>::type & type;
|
||||
};
|
||||
|
||||
//
|
||||
// template expression (i.e., F<...>) specializations
|
||||
//
|
||||
|
||||
#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
template <
|
||||
template <typename...> class F
|
||||
, typename... Ts
|
||||
, typename Dest
|
||||
, typename Source
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(typename Arity)
|
||||
>
|
||||
struct substitute<
|
||||
F<Ts...>
|
||||
, Dest
|
||||
, Source
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(Arity)
|
||||
>
|
||||
{
|
||||
typedef F<typename substitute<
|
||||
Ts, Dest, Source
|
||||
>::type...> type;
|
||||
};
|
||||
#endif // !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES)
|
||||
|
||||
#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_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
|
||||
@@ -0,0 +1,58 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/substitute_fwd.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_SUBSTITUTE_FWD_HPP
|
||||
#define BOOST_VARIANT_DETAIL_SUBSTITUTE_FWD_HPP
|
||||
|
||||
#include <boost/mpl/aux_/lambda_arity_param.hpp>
|
||||
#include <boost/mpl/aux_/template_arity.hpp>
|
||||
#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
|
||||
//
|
||||
// Substitutes one type for another in the given type expression.
|
||||
//
|
||||
template <
|
||||
typename T, typename Dest, typename Source
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(
|
||||
typename Arity = mpl::int_< mpl::aux::template_arity<T>::value >
|
||||
)
|
||||
>
|
||||
struct substitute;
|
||||
|
||||
#endif // !defined(BOOST_VARIANT_DETAIL_NO_SUBSTITUTE)
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_SUBSTITUTE_FWD_HPP
|
||||
@@ -0,0 +1,95 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/variant_io.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-2003
|
||||
// Eric Friedman, Itay Maman
|
||||
//
|
||||
// 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_VARIANT_IO_HPP
|
||||
#define BOOST_VARIANT_DETAIL_VARIANT_IO_HPP
|
||||
|
||||
#include <iosfwd> // for std::basic_ostream forward declare
|
||||
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
#include <boost/detail/templated_streams.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// function template operator<<
|
||||
//
|
||||
// Outputs the content of the given variant to the given ostream.
|
||||
//
|
||||
|
||||
// forward declare (allows output of embedded variant< variant< ... >, ... >)
|
||||
template <
|
||||
BOOST_TEMPLATED_STREAM_ARGS(E,T)
|
||||
BOOST_TEMPLATED_STREAM_COMMA
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename U)
|
||||
>
|
||||
inline BOOST_TEMPLATED_STREAM(ostream, E,T)& operator<<(
|
||||
BOOST_TEMPLATED_STREAM(ostream, E,T)& out
|
||||
, const variant< BOOST_VARIANT_ENUM_PARAMS(U) >& rhs
|
||||
);
|
||||
|
||||
namespace detail { namespace variant {
|
||||
|
||||
template <typename OStream>
|
||||
class printer
|
||||
: public boost::static_visitor<>
|
||||
{
|
||||
private: // representation
|
||||
|
||||
OStream& out_;
|
||||
|
||||
public: // structors
|
||||
|
||||
explicit printer(OStream& out)
|
||||
: out_( out )
|
||||
{
|
||||
}
|
||||
|
||||
public: // visitor interface
|
||||
|
||||
template <typename T>
|
||||
void operator()(const T& operand) const
|
||||
{
|
||||
out_ << operand;
|
||||
}
|
||||
|
||||
private:
|
||||
printer& operator=(const printer&);
|
||||
|
||||
};
|
||||
|
||||
}} // namespace detail::variant
|
||||
|
||||
template <
|
||||
BOOST_TEMPLATED_STREAM_ARGS(E,T)
|
||||
BOOST_TEMPLATED_STREAM_COMMA
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename U)
|
||||
>
|
||||
inline BOOST_TEMPLATED_STREAM(ostream, E,T)& operator<<(
|
||||
BOOST_TEMPLATED_STREAM(ostream, E,T)& out
|
||||
, const variant< BOOST_VARIANT_ENUM_PARAMS(U) >& rhs
|
||||
)
|
||||
{
|
||||
detail::variant::printer<
|
||||
BOOST_TEMPLATED_STREAM(ostream, E,T)
|
||||
> visitor(out);
|
||||
|
||||
rhs.apply_visitor(visitor);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_VARIANT_IO_HPP
|
||||
@@ -0,0 +1,277 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/detail/visitation_impl.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_VISITATION_IMPL_HPP
|
||||
#define BOOST_VARIANT_DETAIL_VISITATION_IMPL_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#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>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/inc.hpp>
|
||||
#include <boost/preprocessor/repeat.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/has_nothrow_copy.hpp>
|
||||
#include <boost/type_traits/is_nothrow_move_constructible.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||
# pragma warning (push)
|
||||
# pragma warning (disable : 4702) //unreachable code
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// BOOST_VARIANT_VISITATION_UNROLLING_LIMIT
|
||||
//
|
||||
// Unrolls variant's visitation mechanism to reduce template instantiation
|
||||
// and potentially increase runtime performance. (TODO: Investigate further.)
|
||||
//
|
||||
#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
|
||||
|
||||
namespace boost {
|
||||
namespace detail { namespace variant {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) class apply_visitor_unrolled
|
||||
//
|
||||
// Tag type indicates when visitation_impl is unrolled.
|
||||
//
|
||||
struct apply_visitor_unrolled {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) class template visitation_impl_step
|
||||
//
|
||||
// "Never ending" iterator range facilitates visitation_impl unrolling.
|
||||
//
|
||||
|
||||
|
||||
template <typename Iter, typename LastIter>
|
||||
struct visitation_impl_step
|
||||
{
|
||||
typedef typename mpl::deref<Iter>::type type;
|
||||
|
||||
typedef typename mpl::next<Iter>::type next_iter;
|
||||
typedef visitation_impl_step<
|
||||
next_iter, LastIter
|
||||
> next;
|
||||
};
|
||||
|
||||
template <typename LastIter>
|
||||
struct visitation_impl_step< LastIter,LastIter >
|
||||
{
|
||||
typedef apply_visitor_unrolled type;
|
||||
typedef visitation_impl_step next;
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) function template visitation_impl_invoke
|
||||
//
|
||||
// Invokes the given visitor on the specified type in the given storage.
|
||||
//
|
||||
|
||||
template <typename Visitor, typename VoidPtrCV, typename T>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
visitation_impl_invoke_impl(
|
||||
int, Visitor& visitor, VoidPtrCV storage, T*
|
||||
, mpl::true_// never_uses_backup
|
||||
)
|
||||
{
|
||||
return visitor.internal_visit(
|
||||
cast_storage<T>(storage), 1L
|
||||
);
|
||||
}
|
||||
|
||||
template <typename Visitor, typename VoidPtrCV, typename T>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
visitation_impl_invoke_impl(
|
||||
int internal_which, Visitor& visitor, VoidPtrCV storage, T*
|
||||
, mpl::false_// never_uses_backup
|
||||
)
|
||||
{
|
||||
if (internal_which >= 0)
|
||||
{
|
||||
return visitor.internal_visit(
|
||||
cast_storage<T>(storage), 1L
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return visitor.internal_visit(
|
||||
cast_storage< backup_holder<T> >(storage), 1L
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Visitor, typename VoidPtrCV, typename T, typename NoBackupFlag>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
visitation_impl_invoke(
|
||||
int internal_which, Visitor& visitor, VoidPtrCV storage, T* t
|
||||
, NoBackupFlag
|
||||
, int
|
||||
)
|
||||
{
|
||||
typedef typename mpl::or_<
|
||||
NoBackupFlag
|
||||
, is_nothrow_move_constructible<T>
|
||||
, has_nothrow_copy<T>
|
||||
>::type never_uses_backup;
|
||||
|
||||
return (visitation_impl_invoke_impl)(
|
||||
internal_which, visitor, storage, t
|
||||
, never_uses_backup()
|
||||
);
|
||||
}
|
||||
|
||||
template <typename Visitor, typename VoidPtrCV, typename NBF>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
visitation_impl_invoke(int, Visitor&, VoidPtrCV, apply_visitor_unrolled*, NBF, long)
|
||||
{
|
||||
// should never be here at runtime!
|
||||
typedef typename Visitor::result_type result_type;
|
||||
return ::boost::detail::variant::forced_return< result_type >();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) function template visitation_impl
|
||||
//
|
||||
// Invokes the given visitor on the type in the given variant storage.
|
||||
//
|
||||
|
||||
template <
|
||||
typename W, typename S
|
||||
, typename Visitor, typename VPCV
|
||||
, typename NBF
|
||||
>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
visitation_impl(
|
||||
int, int, Visitor&, VPCV
|
||||
, mpl::true_ // is_apply_visitor_unrolled
|
||||
, NBF, W* = 0, S* = 0
|
||||
)
|
||||
{
|
||||
// should never be here at runtime!
|
||||
typedef typename Visitor::result_type result_type;
|
||||
return ::boost::detail::variant::forced_return< result_type >();
|
||||
}
|
||||
|
||||
template <
|
||||
typename Which, typename step0
|
||||
, typename Visitor, typename VoidPtrCV
|
||||
, typename NoBackupFlag
|
||||
>
|
||||
inline
|
||||
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
|
||||
visitation_impl(
|
||||
const int internal_which, const int logical_which
|
||||
, Visitor& visitor, VoidPtrCV storage
|
||||
, mpl::false_ // is_apply_visitor_unrolled
|
||||
, NoBackupFlag no_backup_flag
|
||||
, Which* = 0, step0* = 0
|
||||
)
|
||||
{
|
||||
// Typedef apply_visitor_unrolled steps and associated types...
|
||||
# define BOOST_VARIANT_AUX_APPLY_VISITOR_STEP_TYPEDEF(z, N, _) \
|
||||
typedef typename BOOST_PP_CAT(step,N)::type BOOST_PP_CAT(T,N); \
|
||||
typedef typename BOOST_PP_CAT(step,N)::next \
|
||||
BOOST_PP_CAT(step, BOOST_PP_INC(N)); \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_VARIANT_VISITATION_UNROLLING_LIMIT
|
||||
, BOOST_VARIANT_AUX_APPLY_VISITOR_STEP_TYPEDEF
|
||||
, _
|
||||
)
|
||||
|
||||
# undef BOOST_VARIANT_AUX_APPLY_VISITOR_STEP_TYPEDEF
|
||||
|
||||
// ...switch on the target which-index value...
|
||||
switch (logical_which)
|
||||
{
|
||||
|
||||
// ...applying the appropriate case:
|
||||
# define BOOST_VARIANT_AUX_APPLY_VISITOR_STEP_CASE(z, N, _) \
|
||||
case (Which::value + (N)): \
|
||||
return (visitation_impl_invoke)( \
|
||||
internal_which, visitor, storage \
|
||||
, static_cast<BOOST_PP_CAT(T,N)*>(0) \
|
||||
, no_backup_flag, 1L \
|
||||
); \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_VARIANT_VISITATION_UNROLLING_LIMIT
|
||||
, BOOST_VARIANT_AUX_APPLY_VISITOR_STEP_CASE
|
||||
, _
|
||||
)
|
||||
|
||||
# undef BOOST_VARIANT_AUX_APPLY_VISITOR_STEP_CASE
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
// If not handled in this iteration, continue unrolling:
|
||||
typedef mpl::int_<
|
||||
Which::value + (BOOST_VARIANT_VISITATION_UNROLLING_LIMIT)
|
||||
> next_which;
|
||||
|
||||
typedef BOOST_PP_CAT(step, BOOST_VARIANT_VISITATION_UNROLLING_LIMIT)
|
||||
next_step;
|
||||
|
||||
typedef typename next_step::type next_type;
|
||||
typedef typename is_same< next_type,apply_visitor_unrolled >::type
|
||||
is_apply_visitor_unrolled;
|
||||
|
||||
return detail::variant::visitation_impl(
|
||||
internal_which, logical_which
|
||||
, visitor, storage
|
||||
, is_apply_visitor_unrolled()
|
||||
, no_backup_flag
|
||||
, static_cast<next_which*>(0), static_cast<next_step*>(0)
|
||||
);
|
||||
}
|
||||
|
||||
}} // namespace detail::variant
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // BOOST_VARIANT_DETAIL_VISITATION_IMPL_HPP
|
||||
@@ -0,0 +1,313 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/get.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman, Itay Maman
|
||||
// Copyright (c) 2014 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_VARIANT_GET_HPP
|
||||
#define BOOST_VARIANT_GET_HPP
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
#include <boost/variant/detail/element_index.hpp>
|
||||
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/type_traits/add_pointer.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if defined(BOOST_CLANG)
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wweak-vtables"
|
||||
#endif
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// class bad_get
|
||||
//
|
||||
// The exception thrown in the event of a failed get of a value.
|
||||
//
|
||||
class BOOST_SYMBOL_VISIBLE bad_get
|
||||
: public std::exception
|
||||
{
|
||||
public: // std::exception implementation
|
||||
|
||||
virtual const char * what() const BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
return "boost::bad_get: "
|
||||
"failed value get using boost::get";
|
||||
}
|
||||
|
||||
};
|
||||
#if defined(BOOST_CLANG)
|
||||
# pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// function template get<T>
|
||||
//
|
||||
// Retrieves content of given variant object if content is of type T.
|
||||
// Otherwise: pointer ver. returns 0; reference ver. throws bad_get.
|
||||
//
|
||||
|
||||
namespace detail { namespace variant {
|
||||
|
||||
// (detail) class template get_visitor
|
||||
//
|
||||
// Generic static visitor that: if the value is of the specified type,
|
||||
// returns a pointer to the value it visits; else a null pointer.
|
||||
//
|
||||
template <typename T>
|
||||
struct get_visitor
|
||||
{
|
||||
private: // private typedefs
|
||||
|
||||
typedef typename add_pointer<T>::type pointer;
|
||||
typedef typename add_reference<T>::type reference;
|
||||
|
||||
public: // visitor typedefs
|
||||
|
||||
typedef pointer result_type;
|
||||
|
||||
public: // visitor interfaces
|
||||
|
||||
pointer operator()(reference operand) const BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::addressof(operand);
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
pointer operator()(const U&) const BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<pointer>(0);
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail::variant
|
||||
|
||||
#ifndef BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE
|
||||
# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0551))
|
||||
# define BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(t)
|
||||
# else
|
||||
# define BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(t) \
|
||||
, t* = 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// relaxed_get<U>(variant) methods
|
||||
//
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_pointer<U>::type
|
||||
relaxed_get(
|
||||
boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >* operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
typedef typename add_pointer<U>::type U_ptr;
|
||||
if (!operand) return static_cast<U_ptr>(0);
|
||||
|
||||
detail::variant::get_visitor<U> v;
|
||||
return operand->apply_visitor(v);
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_pointer<const U>::type
|
||||
relaxed_get(
|
||||
const boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >* operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
typedef typename add_pointer<const U>::type U_ptr;
|
||||
if (!operand) return static_cast<U_ptr>(0);
|
||||
|
||||
detail::variant::get_visitor<const U> v;
|
||||
return operand->apply_visitor(v);
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_reference<U>::type
|
||||
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 *result;
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_reference<const U>::type
|
||||
relaxed_get(
|
||||
const boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >& operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
)
|
||||
{
|
||||
typedef typename add_pointer<const U>::type U_ptr;
|
||||
U_ptr result = relaxed_get<const U>(boost::addressof(operand));
|
||||
|
||||
if (!result)
|
||||
boost::throw_exception(bad_get());
|
||||
return *result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// strict_get<U>(variant) methods
|
||||
//
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_pointer<U>::type
|
||||
strict_get(
|
||||
boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >* operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
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>(boost::variant<T...>*) will always return NULL"
|
||||
);
|
||||
|
||||
return relaxed_get<U>(operand);
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_pointer<const U>::type
|
||||
strict_get(
|
||||
const boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >* operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
(boost::detail::variant::holds_element<boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >, const U >::value),
|
||||
"boost::variant does not contain specified type U, "
|
||||
"call to boost::get<U>(const boost::variant<T...>*) will always return NULL"
|
||||
);
|
||||
|
||||
return relaxed_get<U>(operand);
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_reference<U>::type
|
||||
strict_get(
|
||||
boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >& operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
)
|
||||
{
|
||||
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>(boost::variant<T...>&) will always throw boost::bad_get exception"
|
||||
);
|
||||
|
||||
return relaxed_get<U>(operand);
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_reference<const U>::type
|
||||
strict_get(
|
||||
const boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >& operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
(boost::detail::variant::holds_element<boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >, const 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>(operand);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// get<U>(variant) methods
|
||||
//
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_pointer<U>::type
|
||||
get(
|
||||
boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >* operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
#ifdef BOOST_VARIANT_USE_RELAXED_GET_BY_DEFAULT
|
||||
return relaxed_get<U>(operand);
|
||||
#else
|
||||
return strict_get<U>(operand);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_pointer<const U>::type
|
||||
get(
|
||||
const boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >* operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
#ifdef BOOST_VARIANT_USE_RELAXED_GET_BY_DEFAULT
|
||||
return relaxed_get<U>(operand);
|
||||
#else
|
||||
return strict_get<U>(operand);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_reference<U>::type
|
||||
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>(operand);
|
||||
#else
|
||||
return strict_get<U>(operand);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_reference<const U>::type
|
||||
get(
|
||||
const 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>(operand);
|
||||
#else
|
||||
return strict_get<U>(operand);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_GET_HPP
|
||||
@@ -0,0 +1,32 @@
|
||||
// Boost.Varaint
|
||||
// Multivisitors defined here
|
||||
//
|
||||
// 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_MULTIVISITORS_HPP
|
||||
#define BOOST_VARIANT_MULTIVISITORS_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp> // for BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
|
||||
|
||||
#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>
|
||||
#endif
|
||||
|
||||
#endif // BOOST_VARIANT_MULTIVISITORS_HPP
|
||||
|
||||
@@ -0,0 +1,346 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/polymorphic_get.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2013-2017 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_VARIANT_POLYMORPHIC_GET_HPP
|
||||
#define BOOST_VARIANT_POLYMORPHIC_GET_HPP
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
#include <boost/variant/get.hpp>
|
||||
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/type_traits/add_pointer.hpp>
|
||||
#include <boost/type_traits/is_base_of.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// class bad_polymorphic_get
|
||||
//
|
||||
// The exception thrown in the event of a failed get of a value.
|
||||
//
|
||||
class BOOST_SYMBOL_VISIBLE bad_polymorphic_get
|
||||
: public bad_get
|
||||
{
|
||||
public: // std::exception implementation
|
||||
|
||||
virtual const char * what() const BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
return "boost::bad_polymorphic_get: "
|
||||
"failed value get using boost::polymorphic_get";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// function template get<T>
|
||||
//
|
||||
// Retrieves content of given variant object if content is of type T.
|
||||
// Otherwise: pointer ver. returns 0; reference ver. throws bad_get.
|
||||
//
|
||||
|
||||
namespace detail { namespace variant {
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// polymorphic metafunctions to detect index of a value
|
||||
//
|
||||
|
||||
template <class Types, class T>
|
||||
struct element_polymorphic_iterator_impl :
|
||||
boost::mpl::find_if<
|
||||
Types,
|
||||
boost::mpl::or_<
|
||||
variant_element_functor<boost::mpl::_1, T>,
|
||||
variant_element_functor<boost::mpl::_1, typename boost::remove_cv<T>::type >,
|
||||
boost::is_base_of<T, boost::mpl::_1>
|
||||
>
|
||||
>
|
||||
{};
|
||||
|
||||
template <class Variant, class T>
|
||||
struct holds_element_polymorphic :
|
||||
boost::mpl::not_<
|
||||
boost::is_same<
|
||||
typename boost::mpl::end<typename Variant::types>::type,
|
||||
typename element_polymorphic_iterator_impl<typename Variant::types, typename boost::remove_reference<T>::type >::type
|
||||
>
|
||||
>
|
||||
{};
|
||||
|
||||
// (detail) class template get_polymorphic_visitor
|
||||
//
|
||||
// Generic static visitor that: if the value is of the specified
|
||||
// type or of a type derived from specified, returns a pointer
|
||||
// to the value it visits; else a null pointer.
|
||||
//
|
||||
template <typename Base>
|
||||
struct get_polymorphic_visitor
|
||||
{
|
||||
private: // private typedefs
|
||||
typedef get_polymorphic_visitor<Base> this_type;
|
||||
typedef typename add_pointer<Base>::type pointer;
|
||||
typedef typename add_reference<Base>::type reference;
|
||||
|
||||
pointer get(reference operand, boost::true_type) const BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::addressof(operand);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
pointer get(T&, boost::false_type) const BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<pointer>(0);
|
||||
}
|
||||
|
||||
public: // visitor interfaces
|
||||
typedef pointer result_type;
|
||||
|
||||
template <typename U>
|
||||
pointer operator()(U& operand) const BOOST_NOEXCEPT
|
||||
{
|
||||
typedef typename boost::remove_reference<Base>::type base_t;
|
||||
typedef boost::integral_constant<
|
||||
bool,
|
||||
(
|
||||
boost::is_base_of<base_t, U>::value &&
|
||||
(boost::is_const<base_t>::value || !boost::is_const<U>::value)
|
||||
)
|
||||
|| boost::is_same<base_t, U>::value
|
||||
|| boost::is_same<typename boost::remove_cv<base_t>::type, U >::value
|
||||
> tag_t;
|
||||
|
||||
return this_type::get(operand, tag_t());
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail::variant
|
||||
|
||||
#ifndef BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE
|
||||
# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0551))
|
||||
# define BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(t)
|
||||
# else
|
||||
# define BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(t) \
|
||||
, t* = 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// polymorphic_relaxed_get
|
||||
//
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_pointer<U>::type
|
||||
polymorphic_relaxed_get(
|
||||
boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >* operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
typedef typename add_pointer<U>::type U_ptr;
|
||||
if (!operand) return static_cast<U_ptr>(0);
|
||||
|
||||
detail::variant::get_polymorphic_visitor<U> v;
|
||||
return operand->apply_visitor(v);
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_pointer<const U>::type
|
||||
polymorphic_relaxed_get(
|
||||
const boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >* operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
typedef typename add_pointer<const U>::type U_ptr;
|
||||
if (!operand) return static_cast<U_ptr>(0);
|
||||
|
||||
detail::variant::get_polymorphic_visitor<const U> v;
|
||||
return operand->apply_visitor(v);
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_reference<U>::type
|
||||
polymorphic_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 = polymorphic_relaxed_get<U>(&operand);
|
||||
|
||||
if (!result)
|
||||
boost::throw_exception(bad_polymorphic_get());
|
||||
return *result;
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_reference<const U>::type
|
||||
polymorphic_relaxed_get(
|
||||
const boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >& operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
)
|
||||
{
|
||||
typedef typename add_pointer<const U>::type U_ptr;
|
||||
U_ptr result = polymorphic_relaxed_get<const U>(&operand);
|
||||
|
||||
if (!result)
|
||||
boost::throw_exception(bad_polymorphic_get());
|
||||
return *result;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// polymorphic_strict_get
|
||||
//
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_pointer<U>::type
|
||||
polymorphic_strict_get(
|
||||
boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >* operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
(boost::detail::variant::holds_element_polymorphic<boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >, U >::value),
|
||||
"boost::variant does not contain specified type U, "
|
||||
"call to boost::polymorphic_get<U>(boost::variant<T...>*) will always return NULL"
|
||||
);
|
||||
|
||||
return polymorphic_relaxed_get<U>(operand);
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_pointer<const U>::type
|
||||
polymorphic_strict_get(
|
||||
const boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >* operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
(boost::detail::variant::holds_element_polymorphic<boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >, U >::value),
|
||||
"boost::variant does not contain specified type U, "
|
||||
"call to boost::polymorphic_get<U>(const boost::variant<T...>*) will always return NULL"
|
||||
);
|
||||
|
||||
return polymorphic_relaxed_get<U>(operand);
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_reference<U>::type
|
||||
polymorphic_strict_get(
|
||||
boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >& operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
(boost::detail::variant::holds_element_polymorphic<boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >, U >::value),
|
||||
"boost::variant does not contain specified type U, "
|
||||
"call to boost::polymorphic_get<U>(boost::variant<T...>&) will always throw boost::bad_polymorphic_get exception"
|
||||
);
|
||||
|
||||
return polymorphic_relaxed_get<U>(operand);
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_reference<const U>::type
|
||||
polymorphic_strict_get(
|
||||
const boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >& operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
(boost::detail::variant::holds_element_polymorphic<boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >, U >::value),
|
||||
"boost::variant does not contain specified type U, "
|
||||
"call to boost::polymorphic_get<U>(const boost::variant<T...>&) will always throw boost::bad_polymorphic_get exception"
|
||||
);
|
||||
|
||||
return polymorphic_relaxed_get<U>(operand);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// polymorphic_get<U>(variant) methods
|
||||
//
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_pointer<U>::type
|
||||
polymorphic_get(
|
||||
boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >* operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
#ifdef BOOST_VARIANT_USE_RELAXED_GET_BY_DEFAULT
|
||||
return polymorphic_relaxed_get<U>(operand);
|
||||
#else
|
||||
return polymorphic_strict_get<U>(operand);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_pointer<const U>::type
|
||||
polymorphic_get(
|
||||
const boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >* operand
|
||||
BOOST_VARIANT_AUX_GET_EXPLICIT_TEMPLATE_TYPE(U)
|
||||
) BOOST_NOEXCEPT
|
||||
{
|
||||
#ifdef BOOST_VARIANT_USE_RELAXED_GET_BY_DEFAULT
|
||||
return polymorphic_relaxed_get<U>(operand);
|
||||
#else
|
||||
return polymorphic_strict_get<U>(operand);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_reference<U>::type
|
||||
polymorphic_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 polymorphic_relaxed_get<U>(operand);
|
||||
#else
|
||||
return polymorphic_strict_get<U>(operand);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename U, BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
inline
|
||||
typename add_reference<const U>::type
|
||||
polymorphic_get(
|
||||
const 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 polymorphic_relaxed_get<U>(operand);
|
||||
#else
|
||||
return polymorphic_strict_get<U>(operand);
|
||||
#endif
|
||||
}
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_POLYMORPHIC_GET_HPP
|
||||
@@ -0,0 +1,209 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/recursive_variant.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman
|
||||
// Copyright (c) 2013 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_VARIANT_RECURSIVE_VARIANT_HPP
|
||||
#define BOOST_VARIANT_RECURSIVE_VARIANT_HPP
|
||||
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
#include <boost/variant/detail/enable_recursive.hpp>
|
||||
#include <boost/variant/detail/substitute_fwd.hpp>
|
||||
#include <boost/variant/detail/make_variant_list.hpp>
|
||||
#include <boost/variant/detail/over_sequence.hpp>
|
||||
|
||||
#include <boost/mpl/aux_/lambda_arity_param.hpp>
|
||||
|
||||
#include <boost/mpl/equal.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/protect.hpp>
|
||||
#include <boost/mpl/transform.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/repeat.hpp>
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/variant/variant.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail { namespace variant {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction specialization substitute
|
||||
//
|
||||
// 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
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(typename Arity)
|
||||
>
|
||||
struct substitute<
|
||||
::boost::variant<
|
||||
recursive_flag< T0 >
|
||||
, BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T)
|
||||
>
|
||||
, RecursiveVariant
|
||||
, ::boost::recursive_variant_
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(Arity)
|
||||
>
|
||||
{
|
||||
typedef ::boost::variant<
|
||||
recursive_flag< T0 >
|
||||
, BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T)
|
||||
> type;
|
||||
};
|
||||
|
||||
template <
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename T)
|
||||
, typename RecursiveVariant
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(typename Arity)
|
||||
>
|
||||
struct substitute<
|
||||
::boost::variant<
|
||||
::boost::detail::variant::over_sequence< T0 >
|
||||
, BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T)
|
||||
>
|
||||
, RecursiveVariant
|
||||
, ::boost::recursive_variant_
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(Arity)
|
||||
>
|
||||
{
|
||||
private:
|
||||
|
||||
typedef T0 initial_types;
|
||||
|
||||
typedef typename mpl::transform<
|
||||
initial_types
|
||||
, mpl::protect< quoted_enable_recursive<RecursiveVariant,mpl::true_> >
|
||||
>::type types;
|
||||
|
||||
public:
|
||||
|
||||
typedef typename mpl::if_<
|
||||
mpl::equal<initial_types, types, ::boost::is_same<mpl::_1, mpl::_2> >
|
||||
, ::boost::variant<
|
||||
::boost::detail::variant::over_sequence< T0 >
|
||||
, BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T)
|
||||
>
|
||||
, ::boost::variant< over_sequence<types> >
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <
|
||||
BOOST_VARIANT_ENUM_PARAMS(typename T)
|
||||
, typename RecursiveVariant
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(typename Arity)
|
||||
>
|
||||
struct substitute<
|
||||
::boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >
|
||||
, RecursiveVariant
|
||||
, ::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
|
||||
, RecursiveVariant
|
||||
, mpl::true_
|
||||
>::type,
|
||||
typename enable_recursive<
|
||||
TN
|
||||
, RecursiveVariant
|
||||
, 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
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// metafunction make_recursive_variant
|
||||
//
|
||||
// See docs and boost/variant/variant_fwd.hpp for more information.
|
||||
//
|
||||
template < BOOST_VARIANT_ENUM_PARAMS(typename T) >
|
||||
struct make_recursive_variant
|
||||
{
|
||||
public: // metafunction result
|
||||
|
||||
typedef boost::variant<
|
||||
detail::variant::recursive_flag< T0 >
|
||||
, BOOST_VARIANT_ENUM_SHIFTED_PARAMS(T)
|
||||
> type;
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// metafunction make_recursive_variant_over
|
||||
//
|
||||
// See docs and boost/variant/variant_fwd.hpp for more information.
|
||||
//
|
||||
template <typename Types>
|
||||
struct make_recursive_variant_over
|
||||
{
|
||||
private: // precondition assertions
|
||||
|
||||
BOOST_STATIC_ASSERT(( ::boost::mpl::is_sequence<Types>::value ));
|
||||
|
||||
public: // metafunction result
|
||||
|
||||
typedef typename make_recursive_variant<
|
||||
detail::variant::over_sequence< Types >
|
||||
>::type type;
|
||||
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_RECURSIVE_VARIANT_HPP
|
||||
@@ -0,0 +1,158 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/recursive_wrapper.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-2003
|
||||
// Eric Friedman, Itay Maman
|
||||
//
|
||||
// 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_RECURSIVE_WRAPPER_HPP
|
||||
#define BOOST_VARIANT_RECURSIVE_WRAPPER_HPP
|
||||
|
||||
#include <boost/variant/recursive_wrapper_fwd.hpp>
|
||||
#include <boost/variant/detail/move.hpp>
|
||||
#include <boost/checked_delete.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// class template recursive_wrapper
|
||||
//
|
||||
// See docs and recursive_wrapper_fwd.hpp for more information.
|
||||
//
|
||||
|
||||
template <typename T>
|
||||
class recursive_wrapper
|
||||
{
|
||||
public: // typedefs
|
||||
|
||||
typedef T type;
|
||||
|
||||
private: // representation
|
||||
|
||||
T* p_;
|
||||
|
||||
public: // structors
|
||||
|
||||
~recursive_wrapper();
|
||||
recursive_wrapper();
|
||||
|
||||
recursive_wrapper(const recursive_wrapper& operand);
|
||||
recursive_wrapper(const T& operand);
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
recursive_wrapper(recursive_wrapper&& operand);
|
||||
recursive_wrapper(T&& operand);
|
||||
#endif
|
||||
|
||||
private: // helpers, for modifiers (below)
|
||||
|
||||
void assign(const T& rhs);
|
||||
|
||||
public: // modifiers
|
||||
|
||||
recursive_wrapper& operator=(const recursive_wrapper& rhs)
|
||||
{
|
||||
assign( rhs.get() );
|
||||
return *this;
|
||||
}
|
||||
|
||||
recursive_wrapper& operator=(const T& rhs)
|
||||
{
|
||||
assign( rhs );
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(recursive_wrapper& operand) BOOST_NOEXCEPT
|
||||
{
|
||||
T* temp = operand.p_;
|
||||
operand.p_ = p_;
|
||||
p_ = temp;
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
recursive_wrapper& operator=(recursive_wrapper&& rhs) BOOST_NOEXCEPT
|
||||
{
|
||||
swap(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
recursive_wrapper& operator=(T&& rhs)
|
||||
{
|
||||
get() = detail::variant::move(rhs);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
public: // queries
|
||||
|
||||
T& get() { return *get_pointer(); }
|
||||
const T& get() const { return *get_pointer(); }
|
||||
|
||||
T* get_pointer() { return p_; }
|
||||
const T* get_pointer() const { return p_; }
|
||||
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
recursive_wrapper<T>::~recursive_wrapper()
|
||||
{
|
||||
boost::checked_delete(p_);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
recursive_wrapper<T>::recursive_wrapper()
|
||||
: p_(new T)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
recursive_wrapper<T>::recursive_wrapper(const recursive_wrapper& operand)
|
||||
: p_(new T( operand.get() ))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
recursive_wrapper<T>::recursive_wrapper(const T& operand)
|
||||
: p_(new T(operand))
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <typename T>
|
||||
recursive_wrapper<T>::recursive_wrapper(recursive_wrapper&& operand)
|
||||
: p_(new T( detail::variant::move(operand.get()) ))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
recursive_wrapper<T>::recursive_wrapper(T&& operand)
|
||||
: p_(new T( detail::variant::move(operand) ))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
void recursive_wrapper<T>::assign(const T& rhs)
|
||||
{
|
||||
this->get() = rhs;
|
||||
}
|
||||
|
||||
// function template swap
|
||||
//
|
||||
// Swaps two recursive_wrapper<T> objects of the same type T.
|
||||
//
|
||||
template <typename T>
|
||||
inline void swap(recursive_wrapper<T>& lhs, recursive_wrapper<T>& rhs) BOOST_NOEXCEPT
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_RECURSIVE_WRAPPER_HPP
|
||||
@@ -0,0 +1,130 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/recursive_wrapper_fwd.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002 Eric Friedman, Itay Maman
|
||||
// Copyright (c) 2016-2017 Antony Polukhin
|
||||
//
|
||||
// Portions Copyright (C) 2002 David Abrahams
|
||||
//
|
||||
// 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_RECURSIVE_WRAPPER_FWD_HPP
|
||||
#define BOOST_VARIANT_RECURSIVE_WRAPPER_FWD_HPP
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/aux_/config/ctps.hpp>
|
||||
#include <boost/mpl/aux_/lambda_support.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/type_traits/is_constructible.hpp>
|
||||
#include <boost/type_traits/is_nothrow_move_constructible.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// class template recursive_wrapper
|
||||
//
|
||||
// Enables recursive types in templates by breaking cyclic dependencies.
|
||||
//
|
||||
// For example:
|
||||
//
|
||||
// class my;
|
||||
//
|
||||
// typedef variant< int, recursive_wrapper<my> > var;
|
||||
//
|
||||
// class my {
|
||||
// var var_;
|
||||
// ...
|
||||
// };
|
||||
//
|
||||
template <typename T> class recursive_wrapper;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// metafunction is_constructible partial specializations.
|
||||
//
|
||||
// recursive_wrapper<T> is constructible only from T and recursive_wrapper<T>.
|
||||
//
|
||||
template <class T> struct is_constructible<recursive_wrapper<T>, T> : boost::true_type{};
|
||||
template <class T> struct is_constructible<recursive_wrapper<T>, const T> : boost::true_type{};
|
||||
template <class T> struct is_constructible<recursive_wrapper<T>, T&> : boost::true_type{};
|
||||
template <class T> struct is_constructible<recursive_wrapper<T>, const T&> : boost::true_type{};
|
||||
template <class T> struct is_constructible<recursive_wrapper<T>, recursive_wrapper<T> > : boost::true_type{};
|
||||
template <class T> struct is_constructible<recursive_wrapper<T>, const recursive_wrapper<T> > : boost::true_type{};
|
||||
template <class T> struct is_constructible<recursive_wrapper<T>, recursive_wrapper<T>& > : boost::true_type{};
|
||||
template <class T> struct is_constructible<recursive_wrapper<T>, const recursive_wrapper<T>& > : boost::true_type{};
|
||||
|
||||
template <class T, class U> struct is_constructible<recursive_wrapper<T>, U > : boost::false_type{};
|
||||
template <class T, class U> struct is_constructible<recursive_wrapper<T>, const U > : boost::false_type{};
|
||||
template <class T, class U> struct is_constructible<recursive_wrapper<T>, U& > : boost::false_type{};
|
||||
template <class T, class U> struct is_constructible<recursive_wrapper<T>, const U& > : boost::false_type{};
|
||||
template <class T, class U> struct is_constructible<recursive_wrapper<T>, recursive_wrapper<U> > : boost::false_type{};
|
||||
template <class T, class U> struct is_constructible<recursive_wrapper<T>, const recursive_wrapper<U> > : boost::false_type{};
|
||||
template <class T, class U> struct is_constructible<recursive_wrapper<T>, recursive_wrapper<U>& > : boost::false_type{};
|
||||
template <class T, class U> struct is_constructible<recursive_wrapper<T>, const recursive_wrapper<U>& > : boost::false_type{};
|
||||
|
||||
// recursive_wrapper is not nothrow move constructible, because it's constructor does dynamic memory allocation.
|
||||
// This specialisation is required to workaround GCC6 issue: https://svn.boost.org/trac/boost/ticket/12680
|
||||
template <class T> struct is_nothrow_move_constructible<recursive_wrapper<T> > : boost::false_type{};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// metafunction is_recursive_wrapper (modeled on code by David Abrahams)
|
||||
//
|
||||
// True if specified type matches recursive_wrapper<T>.
|
||||
//
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct is_recursive_wrapper_impl
|
||||
: mpl::false_
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_recursive_wrapper_impl< recursive_wrapper<T> >
|
||||
: mpl::true_
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template< typename T > struct is_recursive_wrapper
|
||||
: public ::boost::integral_constant<bool,(::boost::detail::is_recursive_wrapper_impl<T>::value)>
|
||||
{
|
||||
public:
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_recursive_wrapper,(T))
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// metafunction unwrap_recursive
|
||||
//
|
||||
// If specified type T matches recursive_wrapper<U>, then U; else T.
|
||||
//
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct unwrap_recursive
|
||||
{
|
||||
typedef T type;
|
||||
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,unwrap_recursive,(T))
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct unwrap_recursive< recursive_wrapper<T> >
|
||||
{
|
||||
typedef T type;
|
||||
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(1,unwrap_recursive,(T))
|
||||
};
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_RECURSIVE_WRAPPER_FWD_HPP
|
||||
@@ -0,0 +1,95 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/static_visitor.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-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_STATIC_VISITOR_HPP
|
||||
#define BOOST_VARIANT_STATIC_VISITOR_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/type_traits/is_base_and_derived.hpp>
|
||||
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/mpl/aux_/lambda_support.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// class template static_visitor
|
||||
//
|
||||
// An empty base class that typedefs the return type of a deriving static
|
||||
// visitor. The class is analogous to std::unary_function in this role.
|
||||
//
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct is_static_visitor_tag { };
|
||||
|
||||
typedef void static_visitor_default_return;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename R = ::boost::detail::static_visitor_default_return>
|
||||
class static_visitor
|
||||
: public detail::is_static_visitor_tag
|
||||
{
|
||||
public: // typedefs
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// metafunction is_static_visitor
|
||||
//
|
||||
// Value metafunction indicates whether the specified type derives from
|
||||
// static_visitor<...>.
|
||||
//
|
||||
// NOTE #1: This metafunction does NOT check whether the specified type
|
||||
// fulfills the requirements of the StaticVisitor concept.
|
||||
//
|
||||
// NOTE #2: This template never needs to be specialized!
|
||||
//
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct is_static_visitor_impl
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
(::boost::is_base_and_derived<
|
||||
detail::is_static_visitor_tag,
|
||||
T
|
||||
>::value));
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template< typename T > struct is_static_visitor
|
||||
: public ::boost::integral_constant<bool,(::boost::detail::is_static_visitor_impl<T>::value)>
|
||||
{
|
||||
public:
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_static_visitor,(T))
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_STATIC_VISITOR_HPP
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,322 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/variant_fwd.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003 Eric Friedman, Itay Maman
|
||||
// Copyright (c) 2013-2016 Antony Polukhin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_VARIANT_VARIANT_FWD_HPP
|
||||
#define BOOST_VARIANT_VARIANT_FWD_HPP
|
||||
|
||||
#include <boost/variant/detail/config.hpp>
|
||||
|
||||
#include <boost/blank_fwd.hpp>
|
||||
#include <boost/mpl/arg.hpp>
|
||||
#include <boost/mpl/limits/arity.hpp>
|
||||
#include <boost/mpl/aux_/na.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/enum.hpp>
|
||||
#include <boost/preprocessor/enum_params.hpp>
|
||||
#include <boost/preprocessor/enum_shifted_params.hpp>
|
||||
#include <boost/preprocessor/repeat.hpp>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT
|
||||
//
|
||||
// Defined if variant does not support make_variant_over (see below).
|
||||
//
|
||||
#if defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
# define BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// macro BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT
|
||||
//
|
||||
// Defined if make_recursive_variant cannot be supported as documented.
|
||||
//
|
||||
// Note: Currently, MPL lambda facility is used as workaround if defined, and
|
||||
// so only types declared w/ MPL lambda workarounds will work.
|
||||
//
|
||||
|
||||
#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)(
|
||||
#define BOOST_VARIANT_CLASS_OR_TYPENAME_TO_SEQ_typename typename)(
|
||||
|
||||
#define BOOST_VARIANT_CLASS_OR_TYPENAME_TO_VARIADIC_class class...
|
||||
#define BOOST_VARIANT_CLASS_OR_TYPENAME_TO_VARIADIC_typename typename...
|
||||
|
||||
#define ARGS_VARIADER_1(x) x ## N...
|
||||
#define ARGS_VARIADER_2(x) BOOST_VARIANT_CLASS_OR_TYPENAME_TO_VARIADIC_ ## x ## N
|
||||
|
||||
#define BOOST_VARIANT_MAKE_VARIADIC(sequence, x) BOOST_VARIANT_MAKE_VARIADIC_I(BOOST_PP_SEQ_SIZE(sequence), x)
|
||||
#define BOOST_VARIANT_MAKE_VARIADIC_I(argscount, x) BOOST_VARIANT_MAKE_VARIADIC_II(argscount, x)
|
||||
#define BOOST_VARIANT_MAKE_VARIADIC_II(argscount, orig) ARGS_VARIADER_ ## argscount(orig)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// BOOST_VARIANT_ENUM_PARAMS and BOOST_VARIANT_ENUM_SHIFTED_PARAMS
|
||||
//
|
||||
// Convenience macro for enumeration of variant params.
|
||||
// When variadic templates are available expands:
|
||||
// BOOST_VARIANT_ENUM_PARAMS(class Something) => class Something0, class... SomethingN
|
||||
// BOOST_VARIANT_ENUM_PARAMS(typename Something) => typename Something0, typename... SomethingN
|
||||
// BOOST_VARIANT_ENUM_PARAMS(Something) => Something0, SomethingN...
|
||||
// BOOST_VARIANT_ENUM_PARAMS(Something) => Something0, SomethingN...
|
||||
// BOOST_VARIANT_ENUM_SHIFTED_PARAMS(class Something) => class... SomethingN
|
||||
// BOOST_VARIANT_ENUM_SHIFTED_PARAMS(typename Something) => typename... SomethingN
|
||||
// BOOST_VARIANT_ENUM_SHIFTED_PARAMS(Something) => SomethingN...
|
||||
// BOOST_VARIANT_ENUM_SHIFTED_PARAMS(Something) => SomethingN...
|
||||
//
|
||||
// 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, \
|
||||
BOOST_VARIANT_MAKE_VARIADIC( (BOOST_VARIANT_CLASS_OR_TYPENAME_TO_SEQ_ ## x), x) \
|
||||
/**/
|
||||
|
||||
#define BOOST_VARIANT_ENUM_SHIFTED_PARAMS(x) \
|
||||
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 {
|
||||
|
||||
namespace detail { namespace variant {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) class void_ and class template convert_void
|
||||
//
|
||||
// Provides the mechanism by which void(NN) types are converted to
|
||||
// mpl::void_ (and thus can be passed to mpl::list).
|
||||
//
|
||||
// Rationale: This is particularly needed for the using-declarations
|
||||
// workaround (below), but also to avoid associating mpl namespace with
|
||||
// variant in argument dependent lookups (which used to happen because of
|
||||
// defaulting of template parameters to mpl::void_).
|
||||
//
|
||||
|
||||
struct void_;
|
||||
|
||||
template <typename T>
|
||||
struct convert_void
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct convert_void< void_ >
|
||||
{
|
||||
typedef mpl::na type;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (workaround) BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE
|
||||
//
|
||||
// Needed to work around compilers that don't support using-declaration
|
||||
// overloads. (See the variant::initializer workarounds below.)
|
||||
//
|
||||
|
||||
#if defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
|
||||
// (detail) tags voidNN -- NN defined on [0, BOOST_VARIANT_LIMIT_TYPES)
|
||||
//
|
||||
// Defines void types that are each unique and specializations of
|
||||
// convert_void that yields mpl::na for each voidNN type.
|
||||
//
|
||||
|
||||
#define BOOST_VARIANT_DETAIL_DEFINE_VOID_N(z,N,_) \
|
||||
struct BOOST_PP_CAT(void,N); \
|
||||
\
|
||||
template <> \
|
||||
struct convert_void< BOOST_PP_CAT(void,N) > \
|
||||
{ \
|
||||
typedef mpl::na type; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_VARIANT_LIMIT_TYPES
|
||||
, BOOST_VARIANT_DETAIL_DEFINE_VOID_N
|
||||
, _
|
||||
)
|
||||
|
||||
#undef BOOST_VARIANT_DETAIL_DEFINE_VOID_N
|
||||
|
||||
#endif // BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE workaround
|
||||
|
||||
}} // 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
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// class template variant (concept inspired by Andrei Alexandrescu)
|
||||
//
|
||||
// Efficient, type-safe bounded discriminated union.
|
||||
//
|
||||
// Preconditions:
|
||||
// - Each type must be unique.
|
||||
// - No type may be const-qualified.
|
||||
//
|
||||
// Proper declaration form:
|
||||
// variant<types> (where types is a type-sequence)
|
||||
// or
|
||||
// variant<T0,T1,...,Tn> (where T0 is NOT a type-sequence)
|
||||
//
|
||||
template < BOOST_VARIANT_AUX_DECLARE_PARAMS > class variant;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// metafunction make_recursive_variant
|
||||
//
|
||||
// Exposes a boost::variant with recursive_variant_ tags (below) substituted
|
||||
// with the variant itself (wrapped as needed with boost::recursive_wrapper).
|
||||
//
|
||||
template < BOOST_VARIANT_AUX_DECLARE_PARAMS > struct make_recursive_variant;
|
||||
|
||||
#undef BOOST_VARIANT_AUX_DECLARE_PARAMS_IMPL
|
||||
#undef BOOST_VARIANT_AUX_DECLARE_PARAMS
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// type recursive_variant_
|
||||
//
|
||||
// Tag type indicates where recursive variant substitution should occur.
|
||||
//
|
||||
#if !defined(BOOST_VARIANT_NO_FULL_RECURSIVE_VARIANT_SUPPORT)
|
||||
struct recursive_variant_ {};
|
||||
#else
|
||||
typedef mpl::arg<1> recursive_variant_;
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// metafunction make_variant_over
|
||||
//
|
||||
// Result is a variant w/ types of the specified type sequence.
|
||||
//
|
||||
template <typename Types> struct make_variant_over;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// metafunction make_recursive_variant_over
|
||||
//
|
||||
// Result is a recursive variant w/ types of the specified type sequence.
|
||||
//
|
||||
template <typename Types> struct make_recursive_variant_over;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_VARIANT_VARIANT_FWD_HPP
|
||||
@@ -0,0 +1,117 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost variant/visitor_ptr.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002-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_VISITOR_PTR_HPP
|
||||
#define BOOST_VARIANT_VISITOR_PTR_HPP
|
||||
|
||||
#include <boost/variant/bad_visit.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
#include <boost/type_traits/is_void.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// function template visitor_ptr
|
||||
//
|
||||
// Adapts a function pointer for use as visitor capable of handling
|
||||
// values of a single type. Throws bad_visit if inappropriately applied.
|
||||
//
|
||||
template <typename T, typename R>
|
||||
class visitor_ptr_t
|
||||
: public static_visitor<R>
|
||||
{
|
||||
private: // representation
|
||||
|
||||
typedef R (*visitor_t)(T);
|
||||
|
||||
visitor_t visitor_;
|
||||
|
||||
public: // typedefs
|
||||
|
||||
typedef R result_type;
|
||||
|
||||
private: // private typedefs
|
||||
|
||||
typedef typename mpl::eval_if<
|
||||
is_reference<T>
|
||||
, mpl::identity<T>
|
||||
, add_reference<const T>
|
||||
>::type argument_fwd_type;
|
||||
|
||||
public: // structors
|
||||
|
||||
explicit visitor_ptr_t(visitor_t visitor) BOOST_NOEXCEPT
|
||||
: visitor_(visitor)
|
||||
{
|
||||
}
|
||||
|
||||
public: // static visitor interfaces
|
||||
|
||||
template <typename U>
|
||||
result_type operator()(const U&) const
|
||||
{
|
||||
boost::throw_exception(bad_visit());
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_VOID_RETURNS)
|
||||
|
||||
public: // static visitor interfaces, cont.
|
||||
|
||||
result_type operator()(argument_fwd_type operand) const
|
||||
{
|
||||
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>
|
||||
inline visitor_ptr_t<T,R> visitor_ptr(R (*visitor)(T))
|
||||
{
|
||||
return visitor_ptr_t<T,R>(visitor);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif// BOOST_VISITOR_VISITOR_PTR_HPP
|
||||
Reference in New Issue
Block a user