Added boost header

This commit is contained in:
Christophe Riccio
2012-01-08 01:26:07 +00:00
parent 9c3faaca40
commit c7d752cdf8
8946 changed files with 1732316 additions and 0 deletions

View File

@@ -0,0 +1,182 @@
//-----------------------------------------------------------------------------
// 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
//
// 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
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)
: 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)
: 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:
//
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
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);
}
#endif // MSVC7 and below exclusion
} // namespace boost
#endif // BOOST_VARIANT_DETAIL_APPLY_VISITOR_BINARY_HPP

View File

@@ -0,0 +1,88 @@
//-----------------------------------------------------------------------------
// 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"
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)
: visitor_(visitor)
{
}
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);
}
private:
apply_visitor_delayed_t& operator=(const apply_visitor_delayed_t&);
};
template <typename Visitor>
inline apply_visitor_delayed_t<Visitor> apply_visitor(Visitor& visitor)
{
return apply_visitor_delayed_t<Visitor>(visitor);
}
} // namespace boost
#endif // BOOST_VARIANT_DETAIL_APPLY_VISITOR_DELAYED_HPP

View File

@@ -0,0 +1,83 @@
//-----------------------------------------------------------------------------
// 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
//
// 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/utility/enable_if.hpp"
#include "boost/mpl/not.hpp"
#include "boost/type_traits/is_const.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:
//
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
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);
}
#endif // MSVC7 and below exclusion
} // namespace boost
#endif // BOOST_VARIANT_DETAIL_APPLY_VISITOR_UNARY_HPP

View File

@@ -0,0 +1,94 @@
//-----------------------------------------------------------------------------
// 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/assert.hpp"
namespace boost {
namespace detail { namespace variant {
template <typename T>
class backup_holder
{
private: // representation
T* backup_;
public: // structors
~backup_holder()
{
delete backup_;
}
explicit backup_holder(T* backup)
: 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)
{
T* tmp = rhs.backup_;
rhs.backup_ = this->backup_;
this->backup_ = tmp;
}
public: // queries
T& get()
{
return *backup_;
}
const T& get() const
{
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)
{
lhs.swap(rhs);
}
}} // namespace detail::variant
} // namespace boost
#endif // BOOST_VARIANT_DETAIL_BACKUP_HOLDER_HPP

View File

@@ -0,0 +1,30 @@
//-----------------------------------------------------------------------------
// boost/variant/detail/bool_trait_def.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)
// Needed until move-related traits incorporated into type_traits library.
// no include guards, the header is intended for multiple inclusion!
// should be the last #include
#include "boost/type_traits/detail/bool_trait_def.hpp"
#define BOOST_VARIANT_TT_AUX_BOOL_TRAIT_DEF1(trait,T,C) \
template< typename T > struct trait \
BOOST_TT_AUX_BOOL_C_BASE(C) \
{ \
BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,trait,(T)) \
}; \
/**/
#define BOOST_VARIANT_TT_AUX_TRAIT_SUFFIX(arity, name) \
BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(arity, name) \
/**/

View File

@@ -0,0 +1,21 @@
//-----------------------------------------------------------------------------
// boost/variant/detail/bool_trait_undef.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)
// Needed until move-related traits incorporated into type_traits library.
// no include guards, the header is intended for multiple inclusion!
// should be the last #include
#include "boost/type_traits/detail/bool_trait_undef.hpp"
#undef BOOST_VARIANT_TT_AUX_BOOL_TRAIT_DEF1
#undef BOOST_VARIANT_TT_AUX_TRAIT_SUFFIX

View File

@@ -0,0 +1,48 @@
//-----------------------------------------------------------------------------
// 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
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)
)
{
return *static_cast<T*>(storage);
}
template <typename T>
inline const T& cast_storage(
const void* storage
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)
)
{
return *static_cast<const T*>(storage);
}
}} // namespace detail::variant
} // namespace boost
#endif // BOOST_VARIANT_DETAIL_CAST_STORAGE_HPP

View File

@@ -0,0 +1,38 @@
//-----------------------------------------------------------------------------
// boost variant/detail/config.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_CONFIG_HPP
#define BOOST_VARIANT_DETAIL_CONFIG_HPP
#include "boost/config.hpp"
#include "boost/detail/workaround.hpp"
///////////////////////////////////////////////////////////////////////////////
// macro BOOST_VARIANT_AUX_BROKEN_CONSTRUCTOR_TEMPLATE_ORDERING
//
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3201) \
|| BOOST_WORKAROUND(BOOST_INTEL, <= 700) \
|| BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
&& !defined(BOOST_VARIANT_AUX_BROKEN_CONSTRUCTOR_TEMPLATE_ORDERING)
# define BOOST_VARIANT_AUX_BROKEN_CONSTRUCTOR_TEMPLATE_ORDERING
#endif
///////////////////////////////////////////////////////////////////////////////
// macro BOOST_VARIANT_AUX_HAS_CONSTRUCTOR_TEMPLATE_ORDERING_SFINAE_WKND
//
#if !defined(BOOST_NO_SFINAE) \
&& !BOOST_WORKAROUND(BOOST_INTEL, <= 700) \
&& !defined(BOOST_VARIANT_AUX_HAS_CONSTRUCTOR_TEMPLATE_ORDERING_SFINAE_WKND)
# define BOOST_VARIANT_AUX_HAS_CONSTRUCTOR_TEMPLATE_ORDERING_SFINAE_WKND
#endif
#endif // BOOST_VARIANT_DETAIL_CONFIG_HPP

View File

@@ -0,0 +1,162 @@
//-----------------------------------------------------------------------------
// 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.
//
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
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;
};
#else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template <typename T, typename RecursiveVariant, typename NoWrapper>
struct enable_recursive
{
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_<
NoWrapper
, is_same< t_,T >
, is_reference<t_>
, is_pointer<t_>
>
, t_
, boost::recursive_wrapper<t_>
>::type type;
};
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround
///////////////////////////////////////////////////////////////////////////////
// (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

View File

@@ -0,0 +1,116 @@
//-----------------------------------------------------------------------------
// 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"
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
# include "boost/mpl/bool.hpp"
#else
# include "boost/type_traits/is_base_and_derived.hpp"
#endif
namespace boost {
namespace detail { namespace variant {
///////////////////////////////////////////////////////////////////////////////
// (detail) tag recursive_flag
//
// Signifies that the variant should perform recursive substituion.
//
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template <typename T>
struct recursive_flag
{
typedef T type;
};
#else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
struct recursive_flag_tag
{
};
template <typename T>
struct recursive_flag
: recursive_flag_tag
{
typedef T type;
};
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround
///////////////////////////////////////////////////////////////////////////////
// (detail) metafunction is_recursive_flag
//
// Signifies that the variant should perform recursive substituion.
//
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template <typename T>
struct is_recursive_flag
: mpl::false_
{
};
template <typename T>
struct is_recursive_flag< recursive_flag<T> >
: mpl::true_
{
};
#else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template <typename T>
struct is_recursive_flag
: is_base_and_derived< recursive_flag_tag,T >
{
};
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround
///////////////////////////////////////////////////////////////////////////////
// (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

View File

@@ -0,0 +1,104 @@
//-----------------------------------------------------------------------------
// boost variant/detail/forced_return.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_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"
#if !defined(BOOST_MSVC) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
# include "boost/type_traits/remove_reference.hpp"
#endif
namespace boost {
namespace detail { namespace variant {
///////////////////////////////////////////////////////////////////////////////
// (detail) function template forced_return
//
// Logical error to permit invocation at runtime, but (artificially) satisfies
// compile-time requirement of returning a result value.
//
#if !defined(BOOST_MSVC) \
&& !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
&& !defined(BOOST_NO_VOID_RETURNS)
// "standard" implementation:
template <typename T>
inline T forced_return( BOOST_EXPLICIT_TEMPLATE_TYPE(T) )
{
// logical error: should never be here! (see above)
BOOST_ASSERT(false);
typedef typename boost::remove_reference<T>::type basic_type;
basic_type* dummy = 0;
return *static_cast< basic_type* >(dummy);
}
template <>
inline void forced_return<void>( BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(void) )
{
// logical error: should never be here! (see above)
BOOST_ASSERT(false);
}
#elif !defined(BOOST_MSVC)
// workaround implementation
//
// TODO: Determine the most efficient way to handle this -- as below? by
// throwing? by recursive call to forced_return itself? etc.
//
template <typename T>
inline
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T)
forced_return( BOOST_EXPLICIT_TEMPLATE_TYPE(T) )
{
// logical error: should never be here! (see above)
BOOST_ASSERT(false);
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T) (*dummy)() = 0;
return dummy();
}
#else // defined(BOOST_MSVC)
// msvc-specific implementation
//
// Leverages __declspec(noreturn) for optimized implementation.
//
__declspec(noreturn)
inline void forced_return_no_return() {};
template <typename T>
inline
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T)
forced_return( BOOST_EXPLICIT_TEMPLATE_TYPE(T) )
{
// logical error: should never be here! (see above)
BOOST_ASSERT(false);
forced_return_no_return();
}
#endif // BOOST_MSVC optimization
}} // namespace detail::variant
} // namespace boost
#endif // BOOST_VARIANT_DETAIL_FORCED_RETURN_HPP

View File

@@ -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

View File

@@ -0,0 +1,106 @@
// (C) Copyright Eric Friedman 2002-2003.
// 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)
//
// See http://www.boost.org for most recent version including documentation.
#ifndef BOOST_VARIANT_DETAIL_HAS_NOTHROW_MOVE_HPP_INCLUDED
#define BOOST_VARIANT_DETAIL_HAS_NOTHROW_MOVE_HPP_INCLUDED
#include "boost/config.hpp" // for STATIC_CONSTANT
#include "boost/variant/detail/has_trivial_move.hpp"
#include "boost/type_traits/has_nothrow_copy.hpp"
#include "boost/type_traits/has_nothrow_assign.hpp"
#include "boost/mpl/and.hpp"
#include "boost/mpl/or.hpp"
// should be the last #include
#include "boost/variant/detail/bool_trait_def.hpp"
namespace boost {
namespace detail { namespace variant {
// TRAIT: has_nothrow_move
template <typename T>
struct has_nothrow_move_impl
{
BOOST_STATIC_CONSTANT(
bool, value = (
::boost::mpl::or_<
has_trivial_move<T>
, ::boost::mpl::and_<
has_nothrow_copy<T>
, has_nothrow_assign<T>
>
>::type::value
)
);
};
BOOST_VARIANT_TT_AUX_BOOL_TRAIT_DEF1(
has_nothrow_move
, T
, (::boost::detail::variant::has_nothrow_move_impl<T>::value)
)
// TRAIT: has_nothrow_move_constructor
template <typename T>
struct has_nothrow_move_constructor_impl
{
BOOST_STATIC_CONSTANT(
bool, value = (
::boost::mpl::or_<
has_nothrow_move<T>
, has_trivial_move_constructor<T>
, has_nothrow_copy<T>
>::type::value
)
);
};
BOOST_VARIANT_TT_AUX_BOOL_TRAIT_DEF1(
has_nothrow_move_constructor
, T
, (::boost::detail::variant::has_nothrow_move_constructor_impl<T>::value)
)
// TRAIT: has_nothrow_move_assign
template <typename T>
struct has_nothrow_move_assign_impl
{
BOOST_STATIC_CONSTANT(
bool, value = (
::boost::mpl::or_<
has_nothrow_move<T>
, has_trivial_move_assign<T>
, has_nothrow_assign<T>
>::type::value
)
);
};
BOOST_VARIANT_TT_AUX_BOOL_TRAIT_DEF1(
has_nothrow_move_assign
, T
, (::boost::detail::variant::has_nothrow_move_assign_impl<T>::value)
)
}} // namespace detail::variant
BOOST_VARIANT_TT_AUX_TRAIT_SUFFIX(1,::boost::detail::variant::has_nothrow_move)
BOOST_VARIANT_TT_AUX_TRAIT_SUFFIX(1,::boost::detail::variant::has_nothrow_move_constructor)
BOOST_VARIANT_TT_AUX_TRAIT_SUFFIX(1,::boost::detail::variant::has_nothrow_move_assign)
} // namespace boost
#include "boost/variant/detail/bool_trait_undef.hpp"
#endif // BOOST_VARIANT_DETAIL_HAS_NOTHROW_MOVE_HPP_INCLUDED

View File

@@ -0,0 +1,100 @@
// (C) Copyright Eric Friedman 2002-2003.
// 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)
//
// See http://www.boost.org for most recent version including documentation.
#ifndef BOOST_VARIANT_DETAIL_HAS_TRIVIAL_MOVE_HPP_INCLUDED
#define BOOST_VARIANT_DETAIL_HAS_TRIVIAL_MOVE_HPP_INCLUDED
#include "boost/config.hpp" // for STATIC_CONSTANT
#include "boost/type_traits/has_trivial_copy.hpp"
#include "boost/type_traits/has_trivial_assign.hpp"
#include "boost/mpl/and.hpp"
#include "boost/mpl/or.hpp"
// should be the last #include
#include "boost/variant/detail/bool_trait_def.hpp"
namespace boost {
namespace detail { namespace variant {
// TRAIT: has_trivial_move
template <typename T>
struct has_trivial_move_impl
{
BOOST_STATIC_CONSTANT(
bool, value = (
::boost::mpl::and_<
has_trivial_copy<T>
, has_trivial_assign<T>
>::type::value
)
);
};
BOOST_VARIANT_TT_AUX_BOOL_TRAIT_DEF1(
has_trivial_move
, T
, (::boost::detail::variant::has_trivial_move_impl<T>::value)
)
// TRAIT: has_trivial_move_constructor
template <typename T>
struct has_trivial_move_constructor_impl
{
BOOST_STATIC_CONSTANT(
bool, value = (
::boost::mpl::or_<
has_trivial_move<T>
, has_trivial_copy<T>
>::type::value
)
);
};
BOOST_VARIANT_TT_AUX_BOOL_TRAIT_DEF1(
has_trivial_move_constructor
, T
, (::boost::detail::variant::has_trivial_move_constructor_impl<T>::value)
)
// TRAIT: has_trivial_move_assign
template <typename T>
struct has_trivial_move_assign_impl
{
BOOST_STATIC_CONSTANT(
bool, value = (
::boost::mpl::or_<
has_trivial_move<T>
, has_trivial_assign<T>
>::type::value
)
);
};
BOOST_VARIANT_TT_AUX_BOOL_TRAIT_DEF1(
has_trivial_move_assign
, T
, (::boost::detail::variant::has_trivial_move_assign_impl<T>::value)
)
}} // namespace detail::variant
BOOST_VARIANT_TT_AUX_TRAIT_SUFFIX(1,::boost::detail::variant::has_trivial_move)
BOOST_VARIANT_TT_AUX_TRAIT_SUFFIX(1,::boost::detail::variant::has_trivial_move_constructor)
BOOST_VARIANT_TT_AUX_TRAIT_SUFFIX(1,::boost::detail::variant::has_trivial_move_assign)
} // namespace boost
#include "boost/variant/detail/bool_trait_undef.hpp"
#endif // BOOST_VARIANT_DETAIL_HAS_TRIVIAL_MOVE_HPP_INCLUDED

View File

@@ -0,0 +1,265 @@
//-----------------------------------------------------------------------------
// 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"
#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;
typedef typename call_traits<public_T>::param_type
param_T;
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
}
};
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)
# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
#define BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_PARAMS \
BOOST_VARIANT_ENUM_PARAMS(typename recursive_enabled_T) \
/**/
#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); \
/**/
# else // MSVC7 and below
#define BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_PARAMS \
BOOST_VARIANT_ENUM_PARAMS(typename recursive_enabled_T) \
, BOOST_VARIANT_ENUM_PARAMS(typename param_T) \
/**/
#define BOOST_VARIANT_AUX_PP_INITIALIZER_DEFINE_PARAM_T(N) \
/**/
# endif // MSVC7 and below workaround
template < BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_PARAMS >
struct preprocessor_list_initializer
{
public: // static functions
#define BOOST_VARIANT_AUX_PP_INITIALIZE_FUNCTION(z,N,_) \
BOOST_VARIANT_AUX_PP_INITIALIZER_DEFINE_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
};
# if defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG)
#if !defined(BOOST_VARIANT_AUX_ECHO)
# define BOOST_VARIANT_AUX_ECHO(z,N,token) token
#endif
template <>
struct preprocessor_list_initializer<
BOOST_PP_ENUM(BOOST_VARIANT_LIMIT_TYPES, BOOST_VARIANT_AUX_ECHO, int)
, BOOST_PP_ENUM(BOOST_VARIANT_LIMIT_TYPES, BOOST_VARIANT_AUX_ECHO, const int)
>
{
};
# endif // BOOST_MPL_CFG_MSVC_60_ETI_BUG workaround
#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)
# if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
#define BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_ARGS(typename_base) \
BOOST_VARIANT_ENUM_PARAMS(typename_base) \
/**/
# else // MSVC7 and below
#define BOOST_VARIANT_AUX_PP_INITIALIZER_ENUM_PARAM_TYPE(z,N,T) \
::boost::call_traits< \
::boost::unwrap_recursive<BOOST_PP_CAT(T,N)>::type \
>::param_type \
/**/
#define BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_ARGS(typename_base) \
BOOST_VARIANT_ENUM_PARAMS(typename_base) \
, BOOST_PP_ENUM( \
BOOST_VARIANT_LIMIT_TYPES \
, BOOST_VARIANT_AUX_PP_INITIALIZER_ENUM_PARAM_TYPE \
, typename_base \
) \
/**/
# endif // MSVC7 workaround
#define BOOST_VARIANT_AUX_INITIALIZER_T( mpl_seq, typename_base ) \
::boost::detail::variant::preprocessor_list_initializer< \
BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_ARGS(typename_base) \
> \
/**/
#endif // BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE workaround
#endif // BOOST_VARIANT_DETAIL_INITIALIZER_HPP

View File

@@ -0,0 +1,60 @@
//-----------------------------------------------------------------------------
// 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
//
// 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).
//
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
};
}} // namespace detail::variant
} // namespace boost
#endif // BOOST_VARIANT_DETAIL_MAKE_VARIANT_LIST_HPP

View File

@@ -0,0 +1,166 @@
//-----------------------------------------------------------------------------
// 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
//
// 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/mpl/if.hpp"
#include "boost/type_traits/is_base_and_derived.hpp"
namespace boost {
namespace detail { namespace variant {
//////////////////////////////////////////////////////////////////////////
// forward declares
//
// NOTE: Incomplete until (if?) Boost.Move becomes part of Boost.
//
template <typename Deriving> class moveable;
template <typename T> class move_source;
template <typename T> class move_return;
namespace detail {
// (detail) moveable_tag
//
// Concrete type from which moveable<T> derives.
//
// TODO: Move into moveable_fwd.hpp and define has_move_constructor.
//
template <typename Deriving>
struct moveable_tag
{
};
} // namespace detail
//////////////////////////////////////////////////////////////////////////
// function template move
//
// Takes a T& and returns, if T derives moveable<T>, a move_source<T> for
// the object; else, returns the T&.
//
namespace detail {
// (detail) class template move_type
//
// Metafunction that, given moveable T, provides move_source<T>, else T&.
//
template <typename T>
struct move_type
{
public: // metafunction result
typedef typename mpl::if_<
is_base_and_derived<detail::moveable_tag<T>, T>
, move_source<T>
, T&
>::type type;
};
} // namespace detail
template <typename T>
inline
typename detail::move_type<T>::type
move(T& source)
{
typedef typename detail::move_type<T>::type
move_t;
return move_t(source);
}
//////////////////////////////////////////////////////////////////////////
// class template return_t
//
// Metafunction that, given moveable T, provides move_return<T>, else T.
//
template <typename T>
struct return_t
{
public: // metafunction result
typedef typename mpl::if_<
is_base_and_derived<moveable<T>, T>
, move_return<T>
, T
>::type type;
};
//////////////////////////////////////////////////////////////////////////
// function template move_swap
//
// Swaps using Koenig lookup but falls back to move-swap for primitive
// types and on non-conforming compilers.
//
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) \
|| BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(2))
// [Indicate that move_swap by overload is disabled...]
#define BOOST_NO_MOVE_SWAP_BY_OVERLOAD
// [...and provide straight swap-by-move implementation:]
template <typename T>
inline void move_swap(T& lhs, T& rhs)
{
T tmp( boost::detail::variant::move(lhs) );
lhs = boost::detail::variant::move(rhs);
rhs = boost::detail::variant::move(tmp);
}
#else// !workaround
namespace detail { namespace move_swap {
template <typename T>
inline void swap(T& lhs, T& rhs)
{
T tmp( boost::detail::variant::move(lhs) );
lhs = boost::detail::variant::move(rhs);
rhs = boost::detail::variant::move(tmp);
}
}} // namespace detail::move_swap
template <typename T>
inline void move_swap(T& lhs, T& rhs)
{
using detail::move_swap::swap;
swap(lhs, rhs);
}
#endif // workaround
}} // namespace detail::variant
} // namespace boost
#endif // BOOST_VARIANT_DETAIL_MOVE_HPP

View File

@@ -0,0 +1,95 @@
//-----------------------------------------------------------------------------
// 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"
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
# include "boost/mpl/eval_if.hpp"
# include "boost/mpl/bool.hpp"
# include "boost/mpl/identity.hpp"
# include "boost/type.hpp"
#endif
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.
//
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template <typename T>
struct is_over_sequence
: mpl::false_
{
};
template <typename Types>
struct is_over_sequence< over_sequence<Types> >
: mpl::true_
{
};
#else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
typedef char (&yes_over_sequence_t)[1];
typedef char (&no_over_sequence_t)[2];
no_over_sequence_t is_over_sequence_test(...);
template<typename T>
yes_over_sequence_t is_over_sequence_test(
type< ::boost::detail::variant::over_sequence<T> >
);
template<typename T>
struct is_over_sequence_impl
{
BOOST_STATIC_CONSTANT(bool, value = (
sizeof(is_over_sequence_test(type<T>()))
== sizeof(yes_over_sequence_t)
));
};
template <typename T>
struct is_over_sequence
: mpl::bool_<
::boost::detail::variant::is_over_sequence_impl<T>::value
>
{
};
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround
}} // namespace detail::variant
} // namespace boost
#endif // BOOST_VARIANT_DETAIL_OVER_SEQUENCE_HPP

View File

@@ -0,0 +1,231 @@
#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/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
//
#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

View File

@@ -0,0 +1,59 @@
//-----------------------------------------------------------------------------
// 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_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
&& !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

View File

@@ -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

View File

@@ -0,0 +1,295 @@
//-----------------------------------------------------------------------------
// 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/assert.hpp"
#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/variant/detail/has_nothrow_move.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)
# define BOOST_VARIANT_VISITATION_UNROLLING_LIMIT \
BOOST_VARIANT_LIMIT_TYPES
#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.
//
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
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;
};
#else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template <typename Iter, typename LastIter>
struct visitation_impl_step
{
typedef typename mpl::eval_if<
is_same<Iter, LastIter>
, mpl::identity<apply_visitor_unrolled>
, Iter
>::type type;
typedef typename mpl::eval_if<
is_same<type, apply_visitor_unrolled> //is_same<Iter, LastIter>
, mpl::identity<LastIter>
, mpl::next<Iter>
>::type next_iter;
typedef visitation_impl_step<
next_iter, LastIter
> next;
};
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround
///////////////////////////////////////////////////////////////////////////////
// (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
, has_nothrow_move_constructor<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:
BOOST_ASSERT(false);
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:
BOOST_ASSERT(false);
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: BOOST_ASSERT(!"Boost.Variant internal error: 'which' out of range.");
}
// 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 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