view release on metacpan or search on metacpan
src/boost/utility/enable_if.hpp
src/boost/utility/identity_type.hpp
src/boost/utility/in_place_factory.hpp
src/boost/utility/result_of.hpp
src/boost/utility/swap.hpp
src/boost/utility/value_init.hpp
src/boost/variant/apply_visitor.hpp
src/boost/variant/detail/apply_visitor_binary.hpp
src/boost/variant/detail/apply_visitor_delayed.hpp
src/boost/variant/detail/apply_visitor_unary.hpp
src/boost/variant/detail/backup_holder.hpp
src/boost/variant/detail/bool_trait_def.hpp
src/boost/variant/detail/bool_trait_undef.hpp
src/boost/variant/detail/cast_storage.hpp
src/boost/variant/detail/config.hpp
src/boost/variant/detail/enable_recursive_fwd.hpp
src/boost/variant/detail/forced_return.hpp
src/boost/variant/detail/generic_result_type.hpp
src/boost/variant/detail/has_nothrow_move.hpp
src/boost/variant/detail/has_trivial_move.hpp
src/boost/variant/detail/hash_variant.hpp
src/boost/variant/detail/backup_holder.hpp view on Meta::CPAN
//-----------------------------------------------------------------------------
// 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()
{
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()
{
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) BOOST_NOEXCEPT
{
lhs.swap(rhs);
}
}} // namespace detail::variant
} // namespace boost
#endif // BOOST_VARIANT_DETAIL_BACKUP_HOLDER_HPP
src/boost/variant/detail/visitation_impl.hpp view on Meta::CPAN
//
// 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"
src/boost/variant/detail/visitation_impl.hpp view on Meta::CPAN
// (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);
src/boost/variant/detail/visitation_impl.hpp view on Meta::CPAN
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)); \
/**/
src/boost/variant/detail/visitation_impl.hpp view on Meta::CPAN
// ...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
src/boost/variant/detail/visitation_impl.hpp view on Meta::CPAN
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
src/boost/variant/variant.hpp view on Meta::CPAN
#if !defined(BOOST_NO_TYPEID)
#include <typeinfo> // for typeid, std::type_info
#endif // BOOST_NO_TYPEID
#include "boost/variant/detail/config.hpp"
#include "boost/mpl/aux_/config/eti.hpp"
#include "boost/mpl/aux_/value_wknd.hpp"
#include "boost/variant/variant_fwd.hpp"
#include "boost/variant/detail/backup_holder.hpp"
#include "boost/variant/detail/enable_recursive_fwd.hpp"
#include "boost/variant/detail/forced_return.hpp"
#include "boost/variant/detail/initializer.hpp"
#include "boost/variant/detail/make_variant_list.hpp"
#include "boost/variant/detail/over_sequence.hpp"
#include "boost/variant/detail/visitation_impl.hpp"
#include "boost/variant/detail/hash_variant.hpp"
#include "boost/variant/detail/generic_result_type.hpp"
#include "boost/variant/detail/has_nothrow_move.hpp"
src/boost/variant/variant.hpp view on Meta::CPAN
template <typename Types, typename NeverUsesBackupFlag>
struct make_storage
{
private: // helpers, for metafunction result (below)
typedef typename mpl::eval_if<
NeverUsesBackupFlag
, mpl::identity< Types >
, mpl::push_front<
Types, backup_holder<void*>
>
>::type types;
typedef typename max_value<
types, mpl::sizeof_<mpl::_1>
>::type max_size;
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0551))
typedef typename mpl::fold<
src/boost/variant/variant.hpp view on Meta::CPAN
explicit copy_into(void* storage) BOOST_NOEXCEPT
: storage_(storage)
{
}
public: // internal visitor interface
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(boost::detail::variant::backup_holder<T>& operand, long) const
{
new(storage_) T( operand.get() );
BOOST_VARIANT_AUX_RETURN_VOID;
}
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(const boost::detail::variant::backup_holder<T>& operand, long) const
{
new(storage_) T( operand.get() );
BOOST_VARIANT_AUX_RETURN_VOID;
}
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(const T& operand, int) const
{
new(storage_) T(operand);
src/boost/variant/variant.hpp view on Meta::CPAN
explicit move_into(void* storage) BOOST_NOEXCEPT
: storage_(storage)
{
}
public: // internal visitor interface
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(boost::detail::variant::backup_holder<T>& operand, long) const
{
new(storage_) T( ::boost::detail::variant::move(operand.get()) );
BOOST_VARIANT_AUX_RETURN_VOID;
}
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(T& operand, int) const BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(T(boost::declval<T>())))
{
new(storage_) T(::boost::detail::variant::move(operand));
src/boost/variant/variant.hpp view on Meta::CPAN
explicit assign_storage(const void* rhs_storage) BOOST_NOEXCEPT
: rhs_storage_(rhs_storage)
{
}
public: // internal visitor interfaces
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(backup_holder<T>& lhs_content, long) const
{
lhs_content.get()
= static_cast< const backup_holder<T>* >(rhs_storage_)->get();
BOOST_VARIANT_AUX_RETURN_VOID;
}
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(const backup_holder<T>& lhs_content, long) const
{
lhs_content.get()
= static_cast< const backup_holder<T>* >(rhs_storage_)->get();
BOOST_VARIANT_AUX_RETURN_VOID;
}
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(T& lhs_content, int) const
{
// NOTE TO USER :
// Compile error here indicates one of variant's bounded types does
// not meet the requirements of the Assignable concept. Thus,
src/boost/variant/variant.hpp view on Meta::CPAN
explicit move_storage(void* rhs_storage) BOOST_NOEXCEPT
: rhs_storage_(rhs_storage)
{
}
public: // internal visitor interfaces
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(backup_holder<T>& lhs_content, long) const
{
lhs_content.get()
= ::boost::detail::variant::move(static_cast<backup_holder<T>* >(rhs_storage_)->get());
BOOST_VARIANT_AUX_RETURN_VOID;
}
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(const backup_holder<T>& lhs_content, long) const
{
lhs_content.get()
= ::boost::detail::variant::move(static_cast<backup_holder<T>* >(rhs_storage_)->get());
BOOST_VARIANT_AUX_RETURN_VOID;
}
template <typename T>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(T& lhs_content, int) const
{
// NOTE TO USER :
// Compile error here indicates one of variant's bounded types does
// not meet the requirements of the Assignable concept. Thus,
src/boost/variant/variant.hpp view on Meta::CPAN
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
private:
// silence MSVC warning C4512: assignment operator could not be generated
direct_mover& operator= (direct_mover const&);
#endif
};
///////////////////////////////////////////////////////////////////////////////
// (detail) class backup_assigner
//
// Internal visitor that "assigns" the given value to the visited value,
// using backup to recover if the destroy-copy sequence fails.
//
// NOTE: This needs to be a friend of variant, as it needs access to
// indicate_which, indicate_backup_which, etc.
//
template <typename Variant>
class backup_assigner
: public static_visitor<>
{
private: // representation
Variant& lhs_;
int rhs_which_;
const void* rhs_content_;
void (*copy_rhs_content_)(void*, const void*);
public: // structors
template<class RhsT>
backup_assigner(Variant& lhs, int rhs_which, const RhsT& rhs_content)
: lhs_(lhs)
, rhs_which_(rhs_which)
, rhs_content_(&rhs_content)
, copy_rhs_content_(&construct_impl<RhsT>)
{
}
private: // helpers, for visitor interface (below)
template<class RhsT>
static void construct_impl(void* addr, const void* obj)
{
new(addr) RhsT(*static_cast<const RhsT*>(obj));
}
template <typename LhsT>
void backup_assign_impl(
LhsT& lhs_content
, mpl::true_// has_nothrow_move
)
{
// Move lhs content to backup...
LhsT backup_lhs_content(
::boost::detail::variant::move(lhs_content)
); // nothrow
// ...destroy lhs content...
lhs_content.~LhsT(); // nothrow
try
{
// ...and attempt to copy rhs content into lhs storage:
copy_rhs_content_(lhs_.storage_.address(), rhs_content_);
}
catch (...)
{
// In case of failure, restore backup content to lhs storage...
new(lhs_.storage_.address())
LhsT(
::boost::detail::variant::move(backup_lhs_content)
); // nothrow
// ...and rethrow:
throw;
}
// In case of success, indicate new content type:
lhs_.indicate_which(rhs_which_); // nothrow
}
template <typename LhsT>
void backup_assign_impl(
LhsT& lhs_content
, mpl::false_// has_nothrow_move
)
{
// Backup lhs content...
LhsT* backup_lhs_ptr = new LhsT(lhs_content);
// ...destroy lhs content...
lhs_content.~LhsT(); // nothrow
try
{
// ...and attempt to copy rhs content into lhs storage:
copy_rhs_content_(lhs_.storage_.address(), rhs_content_);
}
catch (...)
{
// In case of failure, copy backup pointer to lhs storage...
new(lhs_.storage_.address())
backup_holder<LhsT>( backup_lhs_ptr ); // nothrow
// ...indicate now using backup...
lhs_.indicate_backup_which( lhs_.which() ); // nothrow
// ...and rethrow:
throw;
}
// In case of success, indicate new content type...
lhs_.indicate_which(rhs_which_); // nothrow
// ...and delete backup:
delete backup_lhs_ptr; // nothrow
}
public: // visitor interface
template <typename LhsT>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(LhsT& lhs_content, int)
{
typedef typename has_nothrow_move_constructor<LhsT>::type
nothrow_move;
backup_assign_impl( lhs_content, nothrow_move() );
BOOST_VARIANT_AUX_RETURN_VOID;
}
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
private:
// silence MSVC warning C4512: assignment operator could not be generated
backup_assigner& operator= (backup_assigner const&);
#endif
};
///////////////////////////////////////////////////////////////////////////////
// (detail) class swap_with
//
// Visitor that swaps visited value with content of given variant.
//
// Precondition: Given variant MUST have same logical type as visited value.
//
src/boost/variant/variant.hpp view on Meta::CPAN
template <typename T>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
internal_visit(const boost::detail::reference_content<T>& operand, long)
{
return internal_visit( operand.get(), 1L );
}
template <typename T>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
internal_visit(boost::detail::variant::backup_holder<T>& operand, long)
{
return internal_visit( operand.get(), 1L );
}
template <typename T>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)
internal_visit(const boost::detail::variant::backup_holder<T>& operand, long)
{
return internal_visit( operand.get(), 1L );
}
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
private:
// silence MSVC warning C4512: assignment operator could not be generated
invoke_visitor& operator= (invoke_visitor const&);
#endif
};
src/boost/variant/variant.hpp view on Meta::CPAN
fallback_type_;
struct has_fallback_type_
: mpl::not_<
is_same< fallback_type_, detail::variant::no_fallback_type >
>
{
};
typedef has_fallback_type_
never_uses_backup_flag;
typedef typename detail::variant::make_storage<
internal_types, never_uses_backup_flag
>::type storage_t;
private: // helpers, for representation (below)
// which_ on:
// * [0, size<internal_types>) indicates stack content
// * [-size<internal_types>, 0) indicates pointer to heap backup
// if which_ >= 0:
// * then which() -> which_
// * else which() -> -(which_ + 1)
#if !defined(BOOST_VARIANT_MINIMIZE_SIZE)
typedef int which_t;
#else // defined(BOOST_VARIANT_MINIMIZE_SIZE)
src/boost/variant/variant.hpp view on Meta::CPAN
#endif
which_t which_;
storage_t storage_;
void indicate_which(int which_arg) BOOST_NOEXCEPT
{
which_ = static_cast<which_t>( which_arg );
}
void indicate_backup_which(int which_arg) BOOST_NOEXCEPT
{
which_ = static_cast<which_t>( -(which_arg + 1) );
}
private: // helpers, for queries (below)
bool using_backup() const BOOST_NOEXCEPT
{
return which_ < 0;
}
public: // queries
int which() const BOOST_NOEXCEPT
{
// If using heap backup...
if (using_backup())
// ...then return adjusted which_:
return -(which_ + 1);
// Otherwise, return which_ directly:
return which_;
}
private: // helpers, for structors (below)
struct initializer
src/boost/variant/variant.hpp view on Meta::CPAN
return internal_visit( operand.get(), 1L );
}
template <typename T>
int internal_visit(const boost::detail::reference_content<T>& operand, long) const
{
return internal_visit( operand.get(), 1L );
}
template <typename T>
int internal_visit(boost::detail::variant::backup_holder<T>& operand, long) const
{
return internal_visit( operand.get(), 1L );
}
template <typename T>
int internal_visit(const boost::detail::variant::backup_holder<T>& operand, long) const
{
return internal_visit( operand.get(), 1L );
}
template <typename T>
int internal_visit(boost::recursive_wrapper<T>& operand, long) const
{
return internal_visit( operand.get(), 1L );
}
src/boost/variant/variant.hpp view on Meta::CPAN
return internal_visit( operand.get(), 1L );
}
template <typename T>
int internal_visit(const boost::detail::reference_content<T>& operand, long) const
{
return internal_visit( operand.get(), 1L );
}
template <typename T>
int internal_visit(boost::detail::variant::backup_holder<T>& operand, long) const
{
return internal_visit( operand.get(), 1L );
}
template <typename T>
int internal_visit(const boost::detail::variant::backup_holder<T>& operand, long) const
{
return internal_visit( operand.get(), 1L );
}
template <typename T>
int internal_visit(boost::recursive_wrapper<T>& operand, long) const
{
return internal_visit( operand.get(), 1L );
}
src/boost/variant/variant.hpp view on Meta::CPAN
// ...and activate the *this's primary storage on success:
indicate_which(operand.which());
}
#endif
private: // helpers, for modifiers (below)
# if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
template <typename Variant>
friend class detail::variant::backup_assigner;
# endif
// class assigner
//
// Internal visitor that "assigns" the visited value to the given variant
// by appropriate destruction and copy-construction.
//
class assigner
: public static_visitor<>
src/boost/variant/variant.hpp view on Meta::CPAN
}
template <typename RhsT>
void assign_impl(
const RhsT& rhs_content
, mpl::false_// has_nothrow_copy
, mpl::false_// has_nothrow_move_constructor
, mpl::false_// has_fallback_type
)
{
detail::variant::backup_assigner<wknd_self_t>
visitor(lhs_, rhs_which_, rhs_content);
lhs_.internal_apply_visitor(visitor);
}
public: // internal visitor interfaces
template <typename RhsT>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(const RhsT& rhs_content, int)
{
src/boost/variant/variant.hpp view on Meta::CPAN
}
template <typename RhsT>
void assign_impl(
const RhsT& rhs_content
, mpl::false_// has_nothrow_copy
, mpl::false_// has_nothrow_move_constructor
, mpl::false_// has_fallback_type
)
{
detail::variant::backup_assigner<wknd_self_t>
visitor(lhs_, rhs_which_, rhs_content);
lhs_.internal_apply_visitor(visitor);
}
public: // internal visitor interfaces
template <typename RhsT>
BOOST_VARIANT_AUX_RETURN_VOID_TYPE
internal_visit(RhsT& rhs_content, int)
{
src/boost/variant/variant.hpp view on Meta::CPAN
typedef typename mpl::begin<internal_types>::type first_it;
typedef typename mpl::end<internal_types>::type last_it;
typedef detail::variant::visitation_impl_step<
first_it, last_it
> first_step;
return detail::variant::visitation_impl(
internal_which, logical_which
, visitor, storage, mpl::false_()
, never_uses_backup_flag()
, static_cast<first_which*>(0), static_cast<first_step*>(0)
);
}
template <typename Visitor>
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(
typename Visitor::result_type
)
internal_apply_visitor(Visitor& visitor)
{