mirror of
https://github.com/boostorg/any.git
synced 2026-07-21 13:03:30 +00:00
Drop C++03 and C++98 support (#26)
This commit is contained in:
@@ -13,9 +13,6 @@ target_include_directories( boost_any INTERFACE include )
|
||||
target_link_libraries( boost_any
|
||||
INTERFACE
|
||||
Boost::config
|
||||
Boost::core
|
||||
Boost::static_assert
|
||||
Boost::throw_exception
|
||||
Boost::type_index
|
||||
Boost::type_traits
|
||||
)
|
||||
|
||||
+42
-96
@@ -21,19 +21,11 @@
|
||||
#include <boost/any/bad_any_cast.hpp>
|
||||
#include <boost/any/fwd.hpp>
|
||||
#include <boost/any/detail/placeholder.hpp>
|
||||
#include <boost/type_index.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/type_traits/decay.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#include <boost/type_index.hpp>
|
||||
|
||||
#include <memory> // for std::addressof
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -44,7 +36,7 @@ namespace boost
|
||||
public:
|
||||
|
||||
/// \post this->empty() is true.
|
||||
BOOST_CONSTEXPR any() BOOST_NOEXCEPT
|
||||
constexpr any() noexcept
|
||||
: content(0)
|
||||
{
|
||||
}
|
||||
@@ -58,10 +50,10 @@ namespace boost
|
||||
template<typename ValueType>
|
||||
any(const ValueType & value)
|
||||
: content(new holder<
|
||||
BOOST_DEDUCED_TYPENAME remove_cv<BOOST_DEDUCED_TYPENAME decay<const ValueType>::type>::type
|
||||
typename std::remove_cv<typename std::decay<const ValueType>::type>::type
|
||||
>(value))
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
static_assert(
|
||||
!anys::detail::is_basic_any<ValueType>::value,
|
||||
"boost::any shall not be constructed from boost::anys::basic_any"
|
||||
);
|
||||
@@ -80,14 +72,12 @@ namespace boost
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
/// Move constructor that moves content of
|
||||
/// `other` into new instance and leaves `other` empty.
|
||||
///
|
||||
/// \pre C++11 compatible compiler
|
||||
/// \post other->empty() is true
|
||||
/// \throws Nothing.
|
||||
any(any&& other) BOOST_NOEXCEPT
|
||||
any(any&& other) noexcept
|
||||
: content(other.content)
|
||||
{
|
||||
other.content = 0;
|
||||
@@ -97,26 +87,24 @@ namespace boost
|
||||
/// that the initial content of the new instance is equivalent
|
||||
/// in both type and value to `value` before the forward.
|
||||
///
|
||||
/// \pre C++11 compatible compiler.
|
||||
/// \throws std::bad_alloc or any exceptions arising from the move or
|
||||
/// copy constructor of the contained type.
|
||||
template<typename ValueType>
|
||||
any(ValueType&& value
|
||||
, typename boost::disable_if<boost::is_same<any&, ValueType> >::type* = 0 // disable if value has type `any&`
|
||||
, typename boost::disable_if<boost::is_const<ValueType> >::type* = 0) // disable if value has type `const ValueType&&`
|
||||
: content(new holder< typename decay<ValueType>::type >(static_cast<ValueType&&>(value)))
|
||||
, typename std::enable_if<!std::is_same<any&, ValueType>::value >::type* = 0 // disable if value has type `any&`
|
||||
, typename std::enable_if<!std::is_const<ValueType>::value >::type* = 0) // disable if value has type `const ValueType&&`
|
||||
: content(new holder< typename std::decay<ValueType>::type >(std::forward<ValueType>(value)))
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
!anys::detail::is_basic_any<typename boost::decay<ValueType>::type>::value,
|
||||
static_assert(
|
||||
!anys::detail::is_basic_any<typename std::decay<ValueType>::type>::value,
|
||||
"boost::any shall not be constructed from boost::anys::basic_any"
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Releases any and all resources used in management of instance.
|
||||
///
|
||||
/// \throws Nothing.
|
||||
~any() BOOST_NOEXCEPT
|
||||
~any() noexcept
|
||||
{
|
||||
delete content;
|
||||
}
|
||||
@@ -127,7 +115,7 @@ namespace boost
|
||||
///
|
||||
/// \returns `*this`
|
||||
/// \throws Nothing.
|
||||
any & swap(any & rhs) BOOST_NOEXCEPT
|
||||
any & swap(any & rhs) noexcept
|
||||
{
|
||||
placeholder* tmp = content;
|
||||
content = rhs.content;
|
||||
@@ -150,37 +138,15 @@ namespace boost
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
/// Makes a copy of `rhs`,
|
||||
/// discarding previous content, so that the new content of is
|
||||
/// equivalent in both type and value to
|
||||
/// `rhs`.
|
||||
///
|
||||
/// \throws std::bad_alloc
|
||||
/// or any exceptions arising from the copy constructor of the
|
||||
/// contained type. Assignment satisfies the strong guarantee
|
||||
/// of exception safety.
|
||||
template<typename ValueType>
|
||||
any & operator=(const ValueType & rhs)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
!anys::detail::is_basic_any<ValueType>::value,
|
||||
"boost::anys::basic_any shall not be assigned into boost::any"
|
||||
);
|
||||
any(rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
/// Moves content of `rhs` into
|
||||
/// current instance, discarding previous content, so that the
|
||||
/// new content is equivalent in both type and value to the
|
||||
/// content of `rhs` before move, or empty if
|
||||
/// `rhs.empty()`.
|
||||
///
|
||||
/// \pre C++11 compatible compiler.
|
||||
/// \post `rhs->empty()` is true
|
||||
/// \throws Nothing.
|
||||
any & operator=(any&& rhs) BOOST_NOEXCEPT
|
||||
any & operator=(any&& rhs) noexcept
|
||||
{
|
||||
rhs.swap(*this);
|
||||
any().swap(rhs);
|
||||
@@ -192,7 +158,6 @@ namespace boost
|
||||
/// equivalent in both type and value to
|
||||
/// `rhs` before forward.
|
||||
///
|
||||
/// \pre C++11 compatible compiler.
|
||||
/// \throws std::bad_alloc
|
||||
/// or any exceptions arising from the move or copy constructor of the
|
||||
/// contained type. Assignment satisfies the strong guarantee
|
||||
@@ -200,26 +165,25 @@ namespace boost
|
||||
template <class ValueType>
|
||||
any & operator=(ValueType&& rhs)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
!anys::detail::is_basic_any<typename boost::decay<ValueType>::type>::value,
|
||||
static_assert(
|
||||
!anys::detail::is_basic_any<typename std::decay<ValueType>::type>::value,
|
||||
"boost::anys::basic_any shall not be assigned into boost::any"
|
||||
);
|
||||
any(static_cast<ValueType&&>(rhs)).swap(*this);
|
||||
any(std::forward<ValueType>(rhs)).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
public: // queries
|
||||
|
||||
/// \returns `true` if instance is empty, otherwise `false`.
|
||||
/// \throws Nothing.
|
||||
bool empty() const BOOST_NOEXCEPT
|
||||
bool empty() const noexcept
|
||||
{
|
||||
return !content;
|
||||
}
|
||||
|
||||
/// \post this->empty() is true
|
||||
void clear() BOOST_NOEXCEPT
|
||||
void clear() noexcept
|
||||
{
|
||||
any().swap(*this);
|
||||
}
|
||||
@@ -230,16 +194,12 @@ namespace boost
|
||||
///
|
||||
/// Useful for querying against types known either at compile time or
|
||||
/// only at runtime.
|
||||
const boost::typeindex::type_info& type() const BOOST_NOEXCEPT
|
||||
const boost::typeindex::type_info& type() const noexcept
|
||||
{
|
||||
return content ? content->type() : boost::typeindex::type_id<void>().type_info();
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
private: // types
|
||||
#else
|
||||
public: // types (public so any_cast can be non-friend)
|
||||
#endif
|
||||
/// @cond
|
||||
class BOOST_SYMBOL_VISIBLE placeholder: public boost::anys::detail::placeholder
|
||||
{
|
||||
@@ -248,10 +208,7 @@ namespace boost
|
||||
};
|
||||
|
||||
template<typename ValueType>
|
||||
class holder
|
||||
#ifndef BOOST_NO_CXX11_FINAL
|
||||
final
|
||||
#endif
|
||||
class holder final
|
||||
: public placeholder
|
||||
{
|
||||
public: // structors
|
||||
@@ -261,15 +218,14 @@ namespace boost
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
holder(ValueType&& value)
|
||||
: held(static_cast< ValueType&& >(value))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
public: // queries
|
||||
|
||||
const boost::typeindex::type_info& type() const BOOST_NOEXCEPT BOOST_OVERRIDE
|
||||
const boost::typeindex::type_info& type() const noexcept override
|
||||
{
|
||||
return boost::typeindex::type_id<ValueType>().type_info();
|
||||
}
|
||||
@@ -287,27 +243,19 @@ namespace boost
|
||||
holder & operator=(const holder &);
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
|
||||
private: // representation
|
||||
template<typename ValueType>
|
||||
friend ValueType * unsafe_any_cast(any *) BOOST_NOEXCEPT;
|
||||
friend ValueType * unsafe_any_cast(any *) noexcept;
|
||||
|
||||
friend class boost::anys::unique_any;
|
||||
|
||||
#else
|
||||
|
||||
public: // representation (public so any_cast can be non-friend)
|
||||
|
||||
#endif
|
||||
|
||||
placeholder * content;
|
||||
/// @endcond
|
||||
};
|
||||
|
||||
/// Exchange of the contents of `lhs` and `rhs`.
|
||||
/// \throws Nothing.
|
||||
inline void swap(any & lhs, any & rhs) BOOST_NOEXCEPT
|
||||
inline void swap(any & lhs, any & rhs) noexcept
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
@@ -320,15 +268,15 @@ namespace boost
|
||||
// use typeid() comparison, e.g., when our types may travel across
|
||||
// different shared libraries.
|
||||
template<typename ValueType>
|
||||
inline ValueType * unsafe_any_cast(any * operand) BOOST_NOEXCEPT
|
||||
inline ValueType * unsafe_any_cast(any * operand) noexcept
|
||||
{
|
||||
return boost::addressof(
|
||||
return std::addressof(
|
||||
static_cast<any::holder<ValueType> *>(operand->content)->held
|
||||
);
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
inline const ValueType * unsafe_any_cast(const any * operand) BOOST_NOEXCEPT
|
||||
inline const ValueType * unsafe_any_cast(const any * operand) noexcept
|
||||
{
|
||||
return boost::unsafe_any_cast<ValueType>(const_cast<any *>(operand));
|
||||
}
|
||||
@@ -337,17 +285,17 @@ namespace boost
|
||||
/// \returns Pointer to a ValueType stored in `operand`, nullptr if
|
||||
/// `operand` does not contain specified `ValueType`.
|
||||
template<typename ValueType>
|
||||
ValueType * any_cast(any * operand) BOOST_NOEXCEPT
|
||||
ValueType * any_cast(any * operand) noexcept
|
||||
{
|
||||
return operand && operand->type() == boost::typeindex::type_id<ValueType>()
|
||||
? boost::unsafe_any_cast<BOOST_DEDUCED_TYPENAME boost::remove_cv<ValueType>::type>(operand)
|
||||
? boost::unsafe_any_cast<typename std::remove_cv<ValueType>::type>(operand)
|
||||
: 0;
|
||||
}
|
||||
|
||||
/// \returns Const pointer to a ValueType stored in `operand`, nullptr if
|
||||
/// `operand` does not contain specified `ValueType`.
|
||||
template<typename ValueType>
|
||||
inline const ValueType * any_cast(const any * operand) BOOST_NOEXCEPT
|
||||
inline const ValueType * any_cast(const any * operand) noexcept
|
||||
{
|
||||
return boost::any_cast<ValueType>(const_cast<any *>(operand));
|
||||
}
|
||||
@@ -358,9 +306,9 @@ namespace boost
|
||||
template<typename ValueType>
|
||||
ValueType any_cast(any & operand)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref;
|
||||
typedef typename std::remove_reference<ValueType>::type nonref;
|
||||
|
||||
nonref * result = boost::any_cast<nonref>(boost::addressof(operand));
|
||||
nonref * result = boost::any_cast<nonref>(std::addressof(operand));
|
||||
if(!result)
|
||||
boost::throw_exception(bad_any_cast());
|
||||
|
||||
@@ -368,10 +316,10 @@ namespace boost
|
||||
// `ValueType` is not a reference. Example:
|
||||
// `static_cast<std::string>(*result);`
|
||||
// which is equal to `std::string(*result);`
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::conditional<
|
||||
boost::is_reference<ValueType>::value,
|
||||
typedef typename std::conditional<
|
||||
std::is_reference<ValueType>::value,
|
||||
ValueType,
|
||||
BOOST_DEDUCED_TYPENAME boost::add_reference<ValueType>::type
|
||||
typename std::add_lvalue_reference<ValueType>::type
|
||||
>::type ref_type;
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
@@ -390,25 +338,23 @@ namespace boost
|
||||
template<typename ValueType>
|
||||
inline ValueType any_cast(const any & operand)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref;
|
||||
typedef typename std::remove_reference<ValueType>::type nonref;
|
||||
return boost::any_cast<const nonref &>(const_cast<any &>(operand));
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
/// \returns `ValueType` stored in `operand`, leaving the `operand` empty.
|
||||
/// \throws boost::bad_any_cast if `operand` does not contain
|
||||
/// specified `ValueType`.
|
||||
template<typename ValueType>
|
||||
inline ValueType any_cast(any&& operand)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
boost::is_rvalue_reference<ValueType&&>::value /*true if ValueType is rvalue or just a value*/
|
||||
|| boost::is_const< typename boost::remove_reference<ValueType>::type >::value,
|
||||
static_assert(
|
||||
std::is_rvalue_reference<ValueType&&>::value /*true if ValueType is rvalue or just a value*/
|
||||
|| std::is_const< typename std::remove_reference<ValueType>::type >::value,
|
||||
"boost::any_cast shall not be used for getting nonconst references to temporary objects"
|
||||
);
|
||||
return boost::any_cast<ValueType>(operand);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved.
|
||||
|
||||
@@ -32,7 +32,7 @@ class BOOST_SYMBOL_VISIBLE bad_any_cast :
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
const char * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE
|
||||
const char * what() const BOOST_NOEXCEPT_OR_NOTHROW override
|
||||
{
|
||||
return "boost::bad_any_cast: "
|
||||
"failed conversion using boost::any_cast";
|
||||
|
||||
+67
-122
@@ -21,21 +21,12 @@
|
||||
#include <boost/any/bad_any_cast.hpp>
|
||||
#include <boost/any/fwd.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/aligned_storage.hpp>
|
||||
#include <boost/type_index.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/type_traits/decay.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/is_nothrow_move_constructible.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
|
||||
#include <memory> // for std::addressof
|
||||
#include <type_traits>
|
||||
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -63,10 +54,10 @@ namespace anys {
|
||||
template <std::size_t OptimizeForSize, std::size_t OptimizeForAlignment>
|
||||
class basic_any
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(OptimizeForSize > 0 && OptimizeForAlignment > 0, "Size and Align shall be positive values");
|
||||
BOOST_STATIC_ASSERT_MSG(OptimizeForSize >= OptimizeForAlignment, "Size shall non less than Align");
|
||||
BOOST_STATIC_ASSERT_MSG((OptimizeForAlignment & (OptimizeForAlignment - 1)) == 0, "Align shall be a power of 2");
|
||||
BOOST_STATIC_ASSERT_MSG(OptimizeForSize % OptimizeForAlignment == 0, "Size shall be multiple of alignment");
|
||||
static_assert(OptimizeForSize > 0 && OptimizeForAlignment > 0, "Size and Align shall be positive values");
|
||||
static_assert(OptimizeForSize >= OptimizeForAlignment, "Size shall non less than Align");
|
||||
static_assert((OptimizeForAlignment & (OptimizeForAlignment - 1)) == 0, "Align shall be a power of 2");
|
||||
static_assert(OptimizeForSize % OptimizeForAlignment == 0, "Size shall be multiple of alignment");
|
||||
private:
|
||||
/// @cond
|
||||
enum operation
|
||||
@@ -94,11 +85,7 @@ namespace anys {
|
||||
BOOST_ASSERT(!right->empty());
|
||||
BOOST_ASSERT(right->type() == boost::typeindex::type_id<ValueType>());
|
||||
ValueType* value = reinterpret_cast<ValueType*>(&const_cast<basic_any*>(right)->content.small_value);
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
new (&left.content.small_value) ValueType(std::move(*value));
|
||||
#else
|
||||
new (&left.content.small_value) ValueType(*value);
|
||||
#endif
|
||||
left.man = right->man;
|
||||
reinterpret_cast<ValueType const*>(&right->content.small_value)->~ValueType();
|
||||
const_cast<basic_any*>(right)->man = 0;
|
||||
@@ -118,10 +105,10 @@ namespace anys {
|
||||
BOOST_ASSERT(info);
|
||||
BOOST_ASSERT(!left.empty());
|
||||
return boost::typeindex::type_id<ValueType>() == *info ?
|
||||
reinterpret_cast<typename remove_cv<ValueType>::type *>(&left.content.small_value) : 0;
|
||||
reinterpret_cast<typename std::remove_cv<ValueType>::type *>(&left.content.small_value) : 0;
|
||||
case UnsafeCast:
|
||||
BOOST_ASSERT(!left.empty());
|
||||
return reinterpret_cast<typename remove_cv<ValueType>::type *>(&left.content.small_value);
|
||||
return reinterpret_cast<typename std::remove_cv<ValueType>::type *>(&left.content.small_value);
|
||||
case Typeinfo:
|
||||
return const_cast<void*>(static_cast<const void*>(&boost::typeindex::type_id<ValueType>().type_info()));
|
||||
}
|
||||
@@ -160,10 +147,10 @@ namespace anys {
|
||||
BOOST_ASSERT(info);
|
||||
BOOST_ASSERT(!left.empty());
|
||||
return boost::typeindex::type_id<ValueType>() == *info ?
|
||||
static_cast<typename remove_cv<ValueType>::type *>(left.content.large_value) : 0;
|
||||
static_cast<typename std::remove_cv<ValueType>::type *>(left.content.large_value) : 0;
|
||||
case UnsafeCast:
|
||||
BOOST_ASSERT(!left.empty());
|
||||
return reinterpret_cast<typename remove_cv<ValueType>::type *>(left.content.large_value);
|
||||
return reinterpret_cast<typename std::remove_cv<ValueType>::type *>(left.content.large_value);
|
||||
case Typeinfo:
|
||||
return const_cast<void*>(static_cast<const void*>(&boost::typeindex::type_id<ValueType>().type_info()));
|
||||
}
|
||||
@@ -172,56 +159,54 @@ namespace anys {
|
||||
}
|
||||
|
||||
template <typename ValueType>
|
||||
struct is_small_object : boost::integral_constant<bool, sizeof(ValueType) <= OptimizeForSize &&
|
||||
boost::alignment_of<ValueType>::value <= OptimizeForAlignment &&
|
||||
boost::is_nothrow_move_constructible<ValueType>::value>
|
||||
struct is_small_object : std::integral_constant<bool, sizeof(ValueType) <= OptimizeForSize &&
|
||||
alignof(ValueType) <= OptimizeForAlignment &&
|
||||
std::is_nothrow_move_constructible<ValueType>::value>
|
||||
{};
|
||||
|
||||
template <typename ValueType>
|
||||
static void create(basic_any& any, const ValueType& value, boost::true_type)
|
||||
static void create(basic_any& any, const ValueType& value, std::true_type)
|
||||
{
|
||||
typedef typename boost::decay<const ValueType>::type DecayedType;
|
||||
typedef typename std::decay<const ValueType>::type DecayedType;
|
||||
|
||||
any.man = &small_manager<DecayedType>;
|
||||
new (&any.content.small_value) ValueType(value);
|
||||
}
|
||||
|
||||
template <typename ValueType>
|
||||
static void create(basic_any& any, const ValueType& value, boost::false_type)
|
||||
static void create(basic_any& any, const ValueType& value, std::false_type)
|
||||
{
|
||||
typedef typename boost::decay<const ValueType>::type DecayedType;
|
||||
typedef typename std::decay<const ValueType>::type DecayedType;
|
||||
|
||||
any.man = &large_manager<DecayedType>;
|
||||
any.content.large_value = new DecayedType(value);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <typename ValueType>
|
||||
static void create(basic_any& any, ValueType&& value, boost::true_type)
|
||||
static void create(basic_any& any, ValueType&& value, std::true_type)
|
||||
{
|
||||
typedef typename boost::decay<const ValueType>::type DecayedType;
|
||||
typedef typename std::decay<const ValueType>::type DecayedType;
|
||||
any.man = &small_manager<DecayedType>;
|
||||
new (&any.content.small_value) DecayedType(static_cast<ValueType&&>(value));
|
||||
new (&any.content.small_value) DecayedType(std::forward<ValueType>(value));
|
||||
}
|
||||
|
||||
template <typename ValueType>
|
||||
static void create(basic_any& any, ValueType&& value, boost::false_type)
|
||||
static void create(basic_any& any, ValueType&& value, std::false_type)
|
||||
{
|
||||
typedef typename boost::decay<const ValueType>::type DecayedType;
|
||||
typedef typename std::decay<const ValueType>::type DecayedType;
|
||||
any.man = &large_manager<DecayedType>;
|
||||
any.content.large_value = new DecayedType(static_cast<ValueType&&>(value));
|
||||
any.content.large_value = new DecayedType(std::forward<ValueType>(value));
|
||||
}
|
||||
#endif
|
||||
/// @endcond
|
||||
|
||||
public: // non-type template parameters accessors
|
||||
static BOOST_CONSTEXPR_OR_CONST std::size_t buffer_size = OptimizeForSize;
|
||||
static BOOST_CONSTEXPR_OR_CONST std::size_t buffer_align = OptimizeForAlignment;
|
||||
static constexpr std::size_t buffer_size = OptimizeForSize;
|
||||
static constexpr std::size_t buffer_align = OptimizeForAlignment;
|
||||
|
||||
public: // structors
|
||||
|
||||
/// \post this->empty() is true.
|
||||
BOOST_CONSTEXPR basic_any() BOOST_NOEXCEPT
|
||||
constexpr basic_any() noexcept
|
||||
: man(0), content()
|
||||
{
|
||||
}
|
||||
@@ -240,11 +225,11 @@ namespace anys {
|
||||
basic_any(const ValueType & value)
|
||||
: man(0), content()
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
!(boost::is_same<ValueType, boost::any>::value),
|
||||
static_assert(
|
||||
!std::is_same<ValueType, boost::any>::value,
|
||||
"boost::anys::basic_any shall not be constructed from boost::any"
|
||||
);
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
static_assert(
|
||||
!anys::detail::is_basic_any<ValueType>::value,
|
||||
"boost::anys::basic_any<A, B> shall not be constructed from boost::anys::basic_any<C, D>"
|
||||
);
|
||||
@@ -268,14 +253,12 @@ namespace anys {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
/// Move constructor that moves content of
|
||||
/// `other` into new instance and leaves `other` empty.
|
||||
///
|
||||
/// \pre C++11 compatible compiler
|
||||
/// \post other->empty() is true
|
||||
/// \throws Nothing.
|
||||
basic_any(basic_any&& other) BOOST_NOEXCEPT
|
||||
basic_any(basic_any&& other) noexcept
|
||||
: man(0), content()
|
||||
{
|
||||
if (other.man)
|
||||
@@ -292,32 +275,30 @@ namespace anys {
|
||||
/// move constructible and `sizeof(value) <= OptimizeForSize` and
|
||||
/// `alignof(value) <= OptimizeForAlignment`.
|
||||
///
|
||||
/// \pre C++11 compatible compiler.
|
||||
/// \throws std::bad_alloc or any exceptions arising from the move or
|
||||
/// copy constructor of the contained type.
|
||||
template<typename ValueType>
|
||||
basic_any(ValueType&& value
|
||||
, typename boost::disable_if<boost::is_same<basic_any&, ValueType> >::type* = 0 // disable if value has type `basic_any&`
|
||||
, typename boost::disable_if<boost::is_const<ValueType> >::type* = 0) // disable if value has type `const ValueType&&`
|
||||
, typename std::enable_if<!std::is_same<basic_any&, ValueType>::value >::type* = 0 // disable if value has type `basic_any&`
|
||||
, typename std::enable_if<!std::is_const<ValueType>::value >::type* = 0) // disable if value has type `const ValueType&&`
|
||||
: man(0), content()
|
||||
{
|
||||
typedef typename boost::decay<ValueType>::type DecayedType;
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
!(boost::is_same<DecayedType, boost::any>::value),
|
||||
typedef typename std::decay<ValueType>::type DecayedType;
|
||||
static_assert(
|
||||
!std::is_same<DecayedType, boost::any>::value,
|
||||
"boost::anys::basic_any shall not be constructed from boost::any"
|
||||
);
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
static_assert(
|
||||
!anys::detail::is_basic_any<DecayedType>::value,
|
||||
"boost::anys::basic_any<A, B> shall not be constructed from boost::anys::basic_any<C, D>"
|
||||
);
|
||||
create(*this, static_cast<ValueType&&>(value), is_small_object<DecayedType>());
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Releases any and all resources used in management of instance.
|
||||
///
|
||||
/// \throws Nothing.
|
||||
~basic_any() BOOST_NOEXCEPT
|
||||
~basic_any() noexcept
|
||||
{
|
||||
if (man)
|
||||
{
|
||||
@@ -331,7 +312,7 @@ namespace anys {
|
||||
///
|
||||
/// \returns `*this`
|
||||
/// \throws Nothing.
|
||||
basic_any & swap(basic_any & rhs) BOOST_NOEXCEPT
|
||||
basic_any & swap(basic_any & rhs) noexcept
|
||||
{
|
||||
if (this == &rhs)
|
||||
{
|
||||
@@ -371,47 +352,15 @@ namespace anys {
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
/// Makes a copy of `rhs`,
|
||||
/// discarding previous content, so that the new content of is
|
||||
/// equivalent in both type and value to
|
||||
/// `rhs`.
|
||||
///
|
||||
/// Does not dynamically allocate if `ValueType` is nothrow
|
||||
/// move constructible and `sizeof(value) <= OptimizeForSize` and
|
||||
/// `alignof(value) <= OptimizeForAlignment`.
|
||||
///
|
||||
/// \throws std::bad_alloc
|
||||
/// or any exceptions arising from the copy constructor of the
|
||||
/// contained type. Assignment satisfies the strong guarantee
|
||||
/// of exception safety.
|
||||
template<typename ValueType>
|
||||
basic_any & operator=(const ValueType & rhs)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
!(boost::is_same<ValueType, boost::any>::value),
|
||||
"boost::any shall not be assigned into boost::anys::basic_any"
|
||||
);
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
!anys::detail::is_basic_any<ValueType>::value,
|
||||
"boost::anys::basic_any<A, B> shall not be assigned into boost::anys::basic_any<C, D>"
|
||||
);
|
||||
basic_any(rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#else
|
||||
/// Moves content of `rhs` into
|
||||
/// current instance, discarding previous content, so that the
|
||||
/// new content is equivalent in both type and value to the
|
||||
/// content of `rhs` before move, or empty if
|
||||
/// `rhs.empty()`.
|
||||
///
|
||||
/// \pre C++11 compatible compiler.
|
||||
/// \post `rhs->empty()` is true
|
||||
/// \throws Nothing.
|
||||
basic_any & operator=(basic_any&& rhs) BOOST_NOEXCEPT
|
||||
basic_any & operator=(basic_any&& rhs) noexcept
|
||||
{
|
||||
rhs.swap(*this);
|
||||
basic_any().swap(rhs);
|
||||
@@ -427,7 +376,6 @@ namespace anys {
|
||||
/// move constructible and `sizeof(value) <= OptimizeForSize` and
|
||||
/// `alignof(value) <= OptimizeForAlignment`.
|
||||
///
|
||||
/// \pre C++11 compatible compiler.
|
||||
/// \throws std::bad_alloc
|
||||
/// or any exceptions arising from the move or copy constructor of the
|
||||
/// contained type. Assignment satisfies the strong guarantee
|
||||
@@ -435,31 +383,30 @@ namespace anys {
|
||||
template <class ValueType>
|
||||
basic_any & operator=(ValueType&& rhs)
|
||||
{
|
||||
typedef typename boost::decay<ValueType>::type DecayedType;
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
!(boost::is_same<DecayedType, boost::any>::value),
|
||||
typedef typename std::decay<ValueType>::type DecayedType;
|
||||
static_assert(
|
||||
!std::is_same<DecayedType, boost::any>::value,
|
||||
"boost::any shall not be assigned into boost::anys::basic_any"
|
||||
);
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
(!anys::detail::is_basic_any<DecayedType>::value || boost::is_same<DecayedType, basic_any>::value),
|
||||
static_assert(
|
||||
!anys::detail::is_basic_any<DecayedType>::value || std::is_same<DecayedType, basic_any>::value,
|
||||
"boost::anys::basic_any<A, B> shall not be assigned into boost::anys::basic_any<C, D>"
|
||||
);
|
||||
basic_any(static_cast<ValueType&&>(rhs)).swap(*this);
|
||||
basic_any(std::forward<ValueType>(rhs)).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
public: // queries
|
||||
|
||||
/// \returns `true` if instance is empty, otherwise `false`.
|
||||
/// \throws Nothing.
|
||||
bool empty() const BOOST_NOEXCEPT
|
||||
bool empty() const noexcept
|
||||
{
|
||||
return !man;
|
||||
}
|
||||
|
||||
/// \post this->empty() is true
|
||||
void clear() BOOST_NOEXCEPT
|
||||
void clear() noexcept
|
||||
{
|
||||
basic_any().swap(*this);
|
||||
}
|
||||
@@ -480,10 +427,10 @@ namespace anys {
|
||||
private: // representation
|
||||
/// @cond
|
||||
template<typename ValueType, std::size_t Size, std::size_t Alignment>
|
||||
friend ValueType * any_cast(basic_any<Size, Alignment> *) BOOST_NOEXCEPT;
|
||||
friend ValueType * any_cast(basic_any<Size, Alignment> *) noexcept;
|
||||
|
||||
template<typename ValueType, std::size_t Size, std::size_t Alignment>
|
||||
friend ValueType * unsafe_any_cast(basic_any<Size, Alignment> *) BOOST_NOEXCEPT;
|
||||
friend ValueType * unsafe_any_cast(basic_any<Size, Alignment> *) noexcept;
|
||||
|
||||
typedef void*(*manager)(operation op, basic_any& left, const basic_any* right, const boost::typeindex::type_info* info);
|
||||
|
||||
@@ -491,7 +438,7 @@ namespace anys {
|
||||
|
||||
union content {
|
||||
void * large_value;
|
||||
typename boost::aligned_storage<OptimizeForSize, OptimizeForAlignment>::type small_value;
|
||||
alignas(OptimizeForAlignment) unsigned char small_value[OptimizeForSize];
|
||||
} content;
|
||||
/// @endcond
|
||||
};
|
||||
@@ -499,7 +446,7 @@ namespace anys {
|
||||
/// Exchange of the contents of `lhs` and `rhs`.
|
||||
/// \throws Nothing.
|
||||
template<std::size_t OptimizeForSize, std::size_t OptimizeForAlignment>
|
||||
void swap(basic_any<OptimizeForSize, OptimizeForAlignment>& lhs, basic_any<OptimizeForSize, OptimizeForAlignment>& rhs) BOOST_NOEXCEPT
|
||||
void swap(basic_any<OptimizeForSize, OptimizeForAlignment>& lhs, basic_any<OptimizeForSize, OptimizeForAlignment>& rhs) noexcept
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
@@ -507,17 +454,17 @@ namespace anys {
|
||||
/// \returns Pointer to a ValueType stored in `operand`, nullptr if
|
||||
/// `operand` does not contain specified `ValueType`.
|
||||
template<typename ValueType, std::size_t Size, std::size_t Alignment>
|
||||
ValueType * any_cast(basic_any<Size, Alignment> * operand) BOOST_NOEXCEPT
|
||||
ValueType * any_cast(basic_any<Size, Alignment> * operand) noexcept
|
||||
{
|
||||
return operand->man ?
|
||||
static_cast<typename boost::remove_cv<ValueType>::type *>(operand->man(basic_any<Size, Alignment>::AnyCast, *operand, 0, &boost::typeindex::type_id<ValueType>().type_info()))
|
||||
static_cast<typename std::remove_cv<ValueType>::type *>(operand->man(basic_any<Size, Alignment>::AnyCast, *operand, 0, &boost::typeindex::type_id<ValueType>().type_info()))
|
||||
: 0;
|
||||
}
|
||||
|
||||
/// \returns Const pointer to a ValueType stored in `operand`, nullptr if
|
||||
/// `operand` does not contain specified `ValueType`.
|
||||
template<typename ValueType, std::size_t OptimizeForSize, std::size_t OptimizeForAlignment>
|
||||
inline const ValueType * any_cast(const basic_any<OptimizeForSize, OptimizeForAlignment> * operand) BOOST_NOEXCEPT
|
||||
inline const ValueType * any_cast(const basic_any<OptimizeForSize, OptimizeForAlignment> * operand) noexcept
|
||||
{
|
||||
return boost::anys::any_cast<ValueType>(const_cast<basic_any<OptimizeForSize, OptimizeForAlignment> *>(operand));
|
||||
}
|
||||
@@ -528,9 +475,9 @@ namespace anys {
|
||||
template<typename ValueType, std::size_t OptimizeForSize, std::size_t OptimizeForAlignment>
|
||||
ValueType any_cast(basic_any<OptimizeForSize, OptimizeForAlignment> & operand)
|
||||
{
|
||||
typedef typename remove_reference<ValueType>::type nonref;
|
||||
typedef typename std::remove_reference<ValueType>::type nonref;
|
||||
|
||||
nonref * result = boost::anys::any_cast<nonref>(boost::addressof(operand));
|
||||
nonref * result = boost::anys::any_cast<nonref>(std::addressof(operand));
|
||||
if(!result)
|
||||
boost::throw_exception(bad_any_cast());
|
||||
|
||||
@@ -538,10 +485,10 @@ namespace anys {
|
||||
// `ValueType` is not a reference. Example:
|
||||
// `static_cast<std::string>(*result);`
|
||||
// which is equal to `std::string(*result);`
|
||||
typedef typename boost::conditional<
|
||||
boost::is_reference<ValueType>::value,
|
||||
typedef typename std::conditional<
|
||||
std::is_reference<ValueType>::value,
|
||||
ValueType,
|
||||
typename boost::add_reference<ValueType>::type
|
||||
typename std::add_lvalue_reference<ValueType>::type
|
||||
>::type ref_type;
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
@@ -560,25 +507,23 @@ namespace anys {
|
||||
template<typename ValueType, std::size_t OptimizeForSize, std::size_t OptimizeForAlignment>
|
||||
inline ValueType any_cast(const basic_any<OptimizeForSize, OptimizeForAlignment> & operand)
|
||||
{
|
||||
typedef typename remove_reference<ValueType>::type nonref;
|
||||
typedef typename std::remove_reference<ValueType>::type nonref;
|
||||
return boost::anys::any_cast<const nonref &>(const_cast<basic_any<OptimizeForSize, OptimizeForAlignment> &>(operand));
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
/// \returns `ValueType` stored in `operand`, leaving the `operand` empty.
|
||||
/// \throws boost::bad_any_cast if `operand` does not contain
|
||||
/// specified `ValueType`.
|
||||
template<typename ValueType, std::size_t OptimizeForSize, std::size_t OptimizeForAlignment>
|
||||
inline ValueType any_cast(basic_any<OptimizeForSize, OptimizeForAlignment>&& operand)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
boost::is_rvalue_reference<ValueType&&>::value /*true if ValueType is rvalue or just a value*/
|
||||
|| boost::is_const< typename boost::remove_reference<ValueType>::type >::value,
|
||||
static_assert(
|
||||
std::is_rvalue_reference<ValueType&&>::value /*true if ValueType is rvalue or just a value*/
|
||||
|| std::is_const< typename std::remove_reference<ValueType>::type >::value,
|
||||
"boost::any_cast shall not be used for getting nonconst references to temporary objects"
|
||||
);
|
||||
return boost::anys::any_cast<ValueType>(operand);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/// @cond
|
||||
@@ -589,13 +534,13 @@ namespace anys {
|
||||
// use typeid() comparison, e.g., when our types may travel across
|
||||
// different shared libraries.
|
||||
template<typename ValueType, std::size_t OptimizedForSize, std::size_t OptimizeForAlignment>
|
||||
inline ValueType * unsafe_any_cast(basic_any<OptimizedForSize, OptimizeForAlignment> * operand) BOOST_NOEXCEPT
|
||||
inline ValueType * unsafe_any_cast(basic_any<OptimizedForSize, OptimizeForAlignment> * operand) noexcept
|
||||
{
|
||||
return static_cast<ValueType*>(operand->man(basic_any<OptimizedForSize, OptimizeForAlignment>::UnsafeCast, *operand, 0, 0));
|
||||
}
|
||||
|
||||
template<typename ValueType, std::size_t OptimizeForSize, std::size_t OptimizeForAlignment>
|
||||
inline const ValueType * unsafe_any_cast(const basic_any<OptimizeForSize, OptimizeForAlignment> * operand) BOOST_NOEXCEPT
|
||||
inline const ValueType * unsafe_any_cast(const basic_any<OptimizeForSize, OptimizeForAlignment> * operand) noexcept
|
||||
{
|
||||
return boost::anys::unsafe_any_cast<ValueType>(const_cast<basic_any<OptimizeForSize, OptimizeForAlignment> *>(operand));
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace detail {
|
||||
class BOOST_SYMBOL_VISIBLE placeholder {
|
||||
public:
|
||||
virtual ~placeholder() {}
|
||||
virtual const boost::typeindex::type_info& type() const BOOST_NOEXCEPT = 0;
|
||||
virtual const boost::typeindex::type_info& type() const noexcept = 0;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -16,27 +16,6 @@
|
||||
/// \file boost/any/fwd.hpp
|
||||
/// \brief Forward declarations of Boost.Any library types.
|
||||
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \
|
||||
defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) || \
|
||||
defined(BOOST_NO_CXX11_CONSTEXPR) || \
|
||||
defined(BOOST_NO_CXX11_NULLPTR) || \
|
||||
defined(BOOST_NO_CXX11_NOEXCEPT) || \
|
||||
defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || \
|
||||
defined(BOOST_NO_CXX11_FINAL) || \
|
||||
defined(BOOST_NO_CXX11_ALIGNOF) || \
|
||||
defined(BOOST_NO_CXX11_STATIC_ASSERT) || \
|
||||
defined(BOOST_NO_CXX11_SMART_PTR) || \
|
||||
defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) || \
|
||||
defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("C++03 support is deprecated in Boost.Any 1.82 and will be removed in Boost.Any 1.84.")
|
||||
|
||||
#endif
|
||||
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
|
||||
/// @cond
|
||||
namespace boost {
|
||||
|
||||
@@ -46,25 +25,25 @@ namespace anys {
|
||||
|
||||
class unique_any;
|
||||
|
||||
template<std::size_t OptimizeForSize = sizeof(void*), std::size_t OptimizeForAlignment = boost::alignment_of<void*>::value>
|
||||
template<std::size_t OptimizeForSize = sizeof(void*), std::size_t OptimizeForAlignment = alignof(void*)>
|
||||
class basic_any;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <class T>
|
||||
struct is_basic_any: public boost::false_type {};
|
||||
struct is_basic_any: public std::false_type {};
|
||||
|
||||
template<std::size_t OptimizeForSize, std::size_t OptimizeForAlignment>
|
||||
struct is_basic_any<boost::anys::basic_any<OptimizeForSize, OptimizeForAlignment> > : public boost::true_type {};
|
||||
struct is_basic_any<boost::anys::basic_any<OptimizeForSize, OptimizeForAlignment> > : public std::true_type {};
|
||||
|
||||
template <class T>
|
||||
struct is_some_any: public is_basic_any<T> {};
|
||||
|
||||
template <>
|
||||
struct is_some_any<boost::any>: public boost::true_type {};
|
||||
struct is_some_any<boost::any>: public std::true_type {};
|
||||
|
||||
template <>
|
||||
struct is_some_any<boost::anys::unique_any>: public boost::true_type {};
|
||||
struct is_some_any<boost::anys::unique_any>: public std::true_type {};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
@@ -17,23 +17,7 @@
|
||||
/// \file boost/any/unique_any.hpp
|
||||
/// \brief \copybrief boost::anys::unique_any
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
#error Header <boost/any/unique_any.hpp> requires C++11 compatible compiler with move semantics
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
|
||||
#error Header <boost/any/unique_any.hpp> requires C++11 compatible compiler with defaulted functions
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_NO_CXX11_SMART_PTR
|
||||
#error Header <boost/any/unique_any.hpp> requires C++11 compatible standard library with std::unique_ptr
|
||||
#endif
|
||||
#include <memory>
|
||||
|
||||
#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
|
||||
#error Header <boost/any/unique_any.hpp> requires C++11 compatible standard library with std::initializer_list
|
||||
#endif
|
||||
|
||||
#include <memory> // for std::unique_ptr
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
@@ -41,6 +25,7 @@
|
||||
#include <boost/any/bad_any_cast.hpp>
|
||||
#include <boost/any/detail/placeholder.hpp>
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/type_index.hpp>
|
||||
|
||||
namespace boost { namespace anys {
|
||||
@@ -58,8 +43,6 @@ constexpr in_place_type_t<T> in_place_type{};
|
||||
|
||||
/// \brief A class whose instances can hold instances of any
|
||||
/// type (including non-copyable and non-movable types).
|
||||
///
|
||||
/// \pre C++11 compatible compiler.
|
||||
class unique_any {
|
||||
public:
|
||||
/// \post this->has_value() is false.
|
||||
|
||||
+1
-1
@@ -12,5 +12,5 @@
|
||||
"maintainers": [
|
||||
"Antony Polukhin <antoshkka -at- gmail.com>"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
"cxxstd": "11"
|
||||
}
|
||||
|
||||
@@ -8,8 +8,16 @@
|
||||
|
||||
build-project unique_any ;
|
||||
|
||||
import ../../config/checks/config : requires ;
|
||||
|
||||
import testing ;
|
||||
|
||||
project
|
||||
: source-location .
|
||||
: requirements
|
||||
[ requires cxx11_rvalue_references ]
|
||||
;
|
||||
|
||||
test-suite any :
|
||||
[ run any_test.cpp ]
|
||||
[ run any_test.cpp : : : <rtti>off <define>BOOST_NO_RTTI <define>BOOST_NO_TYPEID : any_test_no_rtti ]
|
||||
|
||||
@@ -35,7 +35,6 @@ static void test_with_func()
|
||||
s = boost::any_cast<std::string>(returning_string2());
|
||||
s = boost::any_cast<const std::string&>(returning_string2());
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(__INTEL_COMPILER) && !defined(__ICL) && (!defined(_MSC_VER) || _MSC_VER != 1600)
|
||||
// Intel compiler thinks that it must choose the `any_cast(const any&)` function
|
||||
// instead of the `any_cast(const any&&)`.
|
||||
@@ -54,7 +53,6 @@ static void test_with_func()
|
||||
#endif
|
||||
|
||||
s = boost::any_cast<std::string&&>(returning_string2());
|
||||
#endif
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
@@ -14,18 +14,6 @@
|
||||
|
||||
#include <boost/any.hpp>
|
||||
#include "test.hpp"
|
||||
#include <boost/move/move.hpp>
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_STATIC_ASSERT(false);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -35,5 +23,3 @@ int main()
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -12,18 +12,6 @@
|
||||
|
||||
#include "move_test.hpp"
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main() {
|
||||
return any_tests::move_tests<boost::any>::run_tests();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -14,17 +14,6 @@
|
||||
|
||||
#include <boost/any.hpp>
|
||||
#include "test.hpp"
|
||||
#include <boost/move/move.hpp>
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_STATIC_ASSERT(false);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
int main()
|
||||
@@ -34,5 +23,3 @@ int main()
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+1
-4
@@ -21,7 +21,7 @@ init:
|
||||
# From this point and below code is same for all the Boost libs
|
||||
###############################################################################################################
|
||||
|
||||
version: 1.64.{build}-{branch}
|
||||
version: 1.84.{build}-{branch}
|
||||
|
||||
# branches to build
|
||||
branches:
|
||||
@@ -32,9 +32,6 @@ skip_tags: true
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
|
||||
ADDRMD: 32
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1,clang-win
|
||||
CXXSTD: 14,17
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2013-2019.
|
||||
// Copyright Antony Polukhin, 2013-2023.
|
||||
// Copyright Ruslan Arutyunyan, 2019-2021.
|
||||
//
|
||||
// Distributed under the Boost
|
||||
@@ -15,17 +15,6 @@
|
||||
|
||||
#include <boost/any/basic_any.hpp>
|
||||
#include "test.hpp"
|
||||
#include <boost/move/move.hpp>
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_STATIC_ASSERT(false);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
int main()
|
||||
@@ -36,5 +25,3 @@ int main()
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -20,43 +20,25 @@ struct A {
|
||||
A() {}
|
||||
A(const A&) {}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
A(A&&) BOOST_NOEXCEPT {
|
||||
A(A&&) noexcept {
|
||||
++move_ctors_count;
|
||||
}
|
||||
#endif
|
||||
|
||||
~A() {
|
||||
++destructors_count;
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <class T>
|
||||
T&& portable_move(T& value) {
|
||||
return std::move(value);
|
||||
}
|
||||
#else
|
||||
template <class T>
|
||||
T& portable_move(T& value) {
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
{
|
||||
A a;
|
||||
boost::anys::basic_any<24, 8> any1(a);
|
||||
boost::anys::basic_any<24, 8> any2(portable_move(any1));
|
||||
boost::anys::basic_any<24, 8> any3(portable_move(any2));
|
||||
boost::anys::basic_any<24, 8> any2(std::move(any1));
|
||||
boost::anys::basic_any<24, 8> any3(std::move(any2));
|
||||
BOOST_TEST_EQ(move_ctors_count, 0);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
BOOST_TEST_EQ(destructors_count, 2);
|
||||
#else
|
||||
BOOST_TEST_EQ(destructors_count, 4);
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -13,15 +13,6 @@
|
||||
|
||||
#include "move_test.hpp"
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main() {
|
||||
const int res1 = any_tests::move_tests<boost::anys::basic_any<> >::run_tests();
|
||||
if (res1) return 1;
|
||||
@@ -36,4 +27,3 @@ int main() {
|
||||
if (res4) return 4;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,52 +20,27 @@ struct A {
|
||||
A() {}
|
||||
A(const A&) {}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
A(A&&) BOOST_NOEXCEPT {
|
||||
A(A&&) noexcept {
|
||||
++move_ctors_count;
|
||||
}
|
||||
#endif
|
||||
|
||||
~A() {
|
||||
++destructors_count;
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template <class T>
|
||||
T&& portable_move(T& value) {
|
||||
return std::move(value);
|
||||
}
|
||||
#else
|
||||
template <class T>
|
||||
T& portable_move(T& value) {
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int main() {
|
||||
#if !defined(__GNUC__) || __GNUC__ > 4
|
||||
{
|
||||
A a;
|
||||
boost::anys::basic_any<24, 8> any1(a);
|
||||
boost::anys::basic_any<24, 8> any2(portable_move(any1));
|
||||
boost::anys::basic_any<24, 8> any3(portable_move(any2));
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_NOEXCEPT)
|
||||
boost::anys::basic_any<24, 8> any2(std::move(any1));
|
||||
boost::anys::basic_any<24, 8> any3(std::move(any2));
|
||||
BOOST_TEST_EQ(move_ctors_count, 2);
|
||||
#else
|
||||
BOOST_TEST_EQ(move_ctors_count, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
// The move constructor is not marked with noexcept, so the large_manager is used.
|
||||
// Moving large_manager data is just swapping pointers without calling destructors.
|
||||
BOOST_TEST_EQ(destructors_count, 2);
|
||||
#else
|
||||
BOOST_TEST_EQ(destructors_count, 4);
|
||||
#endif
|
||||
|
||||
#endif // #if !defined(__GNUC__) || __GNUC__ > 4
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -15,18 +15,6 @@
|
||||
|
||||
#include <boost/any/basic_any.hpp>
|
||||
#include "test.hpp"
|
||||
#include <boost/move/move.hpp>
|
||||
|
||||
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_STATIC_ASSERT(false);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -35,5 +23,3 @@ int main()
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+1
-18
@@ -18,8 +18,6 @@
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/type_index.hpp>
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
namespace any_tests {
|
||||
|
||||
template <typename Any>
|
||||
@@ -108,25 +106,19 @@ struct move_tests // test definitions
|
||||
move_copy_conting_class value0;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
Any value(boost::move(value0));
|
||||
#else
|
||||
Any value(value0);
|
||||
#endif
|
||||
|
||||
check_false(value.empty(), "empty");
|
||||
check_equal(value.type(), boost::typeindex::type_id<move_copy_conting_class>(), "type");
|
||||
check_non_null(boost::any_cast<move_copy_conting_class>(&value), "any_cast<move_copy_conting_class>");
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
check_equal(
|
||||
move_copy_conting_class::copy_count, 0u,
|
||||
"checking copy counts");
|
||||
check_equal(
|
||||
move_copy_conting_class::moves_count, 1u,
|
||||
"checking move counts");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void test_move_assignment_from_value()
|
||||
@@ -135,25 +127,18 @@ struct move_tests // test definitions
|
||||
Any value;
|
||||
move_copy_conting_class::copy_count = 0;
|
||||
move_copy_conting_class::moves_count = 0;
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
value = boost::move(value0);
|
||||
#else
|
||||
value = value0;
|
||||
#endif
|
||||
|
||||
check_false(value.empty(), "empty");
|
||||
check_equal(value.type(), boost::typeindex::type_id<move_copy_conting_class>(), "type");
|
||||
check_non_null(boost::any_cast<move_copy_conting_class>(&value), "any_cast<move_copy_conting_class>");
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
check_equal(
|
||||
move_copy_conting_class::copy_count, 0u,
|
||||
"checking copy counts");
|
||||
check_equal(
|
||||
move_copy_conting_class::moves_count, 1u,
|
||||
"checking move counts");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void test_copy_construction_from_value()
|
||||
@@ -299,5 +284,3 @@ unsigned int move_tests<Any>::move_copy_conting_class::copy_count = 0;
|
||||
} // namespace any_tests
|
||||
|
||||
#endif // BOOST_ANY_TESTS_MOVE_TEST_HPP_INCLUDED
|
||||
|
||||
#endif // MOVE_TEST_INCLUDED
|
||||
|
||||
@@ -15,7 +15,7 @@ import testing ;
|
||||
project
|
||||
: source-location .
|
||||
: requirements
|
||||
[ requires cxx11 ]
|
||||
[ requires cxx11_rvalue_references ]
|
||||
;
|
||||
|
||||
test-suite unique_any :
|
||||
|
||||
Reference in New Issue
Block a user