mirror of
https://github.com/boostorg/move.git
synced 2025-08-02 05:44:25 +02:00
Merge branch 'develop'
This commit is contained in:
@@ -24,7 +24,12 @@ doxygen autodoc
|
|||||||
<doxygen:param>"PREDEFINED=\"BOOST_MOVE_DOXYGEN_INVOKED\" \\
|
<doxygen:param>"PREDEFINED=\"BOOST_MOVE_DOXYGEN_INVOKED\" \\
|
||||||
\"BOOST_MOVE_SEEDOC(T)=see_documentation\" \\
|
\"BOOST_MOVE_SEEDOC(T)=see_documentation\" \\
|
||||||
\"BOOST_RV_REF(T)=T&&\" \\
|
\"BOOST_RV_REF(T)=T&&\" \\
|
||||||
|
\"BOOST_RV_REF_BEG=\" \\
|
||||||
|
\"BOOST_RV_REF_END=&&\" \\
|
||||||
\"BOOST_FWD_REF(T)=T&&\" \\
|
\"BOOST_FWD_REF(T)=T&&\" \\
|
||||||
|
\"BOOST_MOVE_DOC0PTR(T)=std::nullptr_t\" \\
|
||||||
|
\"BOOST_MOVE_DOC1ST(T1, T2)=T1\" \\
|
||||||
|
\"BOOST_MOVE_DOCIGN(T1) \"\\
|
||||||
"
|
"
|
||||||
;
|
;
|
||||||
|
|
||||||
|
185
include/boost/move/default_delete.hpp
Normal file
185
include/boost/move/default_delete.hpp
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Ion Gaztanaga 2014-2014. Distributed under the Boost
|
||||||
|
// Software License, Version 1.0. (See accompanying file
|
||||||
|
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/move for documentation.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef BOOST_MOVE_DEFAULT_DELETE_HPP_INCLUDED
|
||||||
|
#define BOOST_MOVE_DEFAULT_DELETE_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include <boost/move/detail/config_begin.hpp>
|
||||||
|
#include <boost/move/detail/workaround.hpp>
|
||||||
|
#include <boost/move/detail/unique_ptr_meta_utils.hpp>
|
||||||
|
#include <boost/move/utility_core.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
|
||||||
|
#include <cstddef> //For std::size_t
|
||||||
|
|
||||||
|
//!\file
|
||||||
|
//! Describes the default deleter (destruction policy) of <tt>unique_ptr</tt>: <tt>default_delete</tt>.
|
||||||
|
|
||||||
|
namespace boost{
|
||||||
|
namespace move_upd {
|
||||||
|
|
||||||
|
namespace bmupmu = ::boost::move_upmu;
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
//// enable_def_del
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
//compatible with a pointer type T*:
|
||||||
|
//When either Y* is convertible to T*
|
||||||
|
//Y is U[N] and T is U cv []
|
||||||
|
template<class U, class T>
|
||||||
|
struct def_del_compatible_cond
|
||||||
|
: bmupmu::is_convertible<U*, T*>
|
||||||
|
{};
|
||||||
|
|
||||||
|
template<class U, class T, std::size_t N>
|
||||||
|
struct def_del_compatible_cond<U[N], T[]>
|
||||||
|
: def_del_compatible_cond<U[], T[]>
|
||||||
|
{};
|
||||||
|
|
||||||
|
template<class U, class T, class Type = bmupmu::nat>
|
||||||
|
struct enable_def_del
|
||||||
|
: bmupmu::enable_if_c<def_del_compatible_cond<U, T>::value, Type>
|
||||||
|
{};
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
//// enable_defdel_call
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
//When 2nd is T[N], 1st(*)[N] shall be convertible to T(*)[N];
|
||||||
|
//When 2nd is T[], 1st(*)[] shall be convertible to T(*)[];
|
||||||
|
//Otherwise, 1st* shall be convertible to 2nd*.
|
||||||
|
|
||||||
|
template<class U, class T, class Type = bmupmu::nat>
|
||||||
|
struct enable_defdel_call
|
||||||
|
: public enable_def_del<U, T, Type>
|
||||||
|
{};
|
||||||
|
|
||||||
|
template<class U, class T, class Type>
|
||||||
|
struct enable_defdel_call<U, T[], Type>
|
||||||
|
: public enable_def_del<U[], T[], Type>
|
||||||
|
{};
|
||||||
|
|
||||||
|
template<class U, class T, class Type, std::size_t N>
|
||||||
|
struct enable_defdel_call<U, T[N], Type>
|
||||||
|
: public enable_def_del<U[N], T[N], Type>
|
||||||
|
{};
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
//// Some bool literal zero conversion utilities
|
||||||
|
////////////////////////////////////////
|
||||||
|
|
||||||
|
struct bool_conversion {int for_bool; int for_arg(); };
|
||||||
|
typedef int bool_conversion::* explicit_bool_arg;
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_NULLPTR)
|
||||||
|
typedef std::nullptr_t nullptr_type;
|
||||||
|
#else
|
||||||
|
typedef int (bool_conversion::*nullptr_type)();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} //namespace move_upd {
|
||||||
|
|
||||||
|
namespace movelib {
|
||||||
|
|
||||||
|
namespace bmupd = boost::move_upd;
|
||||||
|
namespace bmupmu = boost::move_detail;
|
||||||
|
|
||||||
|
//!The class template <tt>default_delete</tt> serves as the default deleter
|
||||||
|
//!(destruction policy) for the class template <tt>unique_ptr</tt>.
|
||||||
|
//!
|
||||||
|
//! \tparam T The type to be deleted. It may be an incomplete type
|
||||||
|
template <class T>
|
||||||
|
struct default_delete
|
||||||
|
{
|
||||||
|
//! Default constructor.
|
||||||
|
//!
|
||||||
|
BOOST_CONSTEXPR default_delete()
|
||||||
|
//Avoid "defaulted on its first declaration must not have an exception-specification" error for GCC 4.6
|
||||||
|
#if !defined(BOOST_GCC) || (BOOST_GCC < 40600 && BOOST_GCC >= 40700) || defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||||
|
BOOST_NOEXCEPT
|
||||||
|
#endif
|
||||||
|
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||||
|
= default;
|
||||||
|
#else
|
||||||
|
{};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||||
|
default_delete(const default_delete&) BOOST_NOEXCEPT = default;
|
||||||
|
default_delete &operator=(const default_delete&) BOOST_NOEXCEPT = default;
|
||||||
|
#else
|
||||||
|
typedef typename bmupmu::remove_extent<T>::type element_type;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//! <b>Effects</b>: Constructs a default_delete object from another <tt>default_delete<U></tt> object.
|
||||||
|
//!
|
||||||
|
//! <b>Remarks</b>: This constructor shall not participate in overload resolution unless:
|
||||||
|
//! - If T is not an array type and U* is implicitly convertible to T*.
|
||||||
|
//! - If T is an array type and U* is a more CV qualified pointer to remove_extent<T>::type.
|
||||||
|
template <class U>
|
||||||
|
default_delete(const default_delete<U>&
|
||||||
|
BOOST_MOVE_DOCIGN(BOOST_MOVE_I typename bmupd::enable_def_del<U BOOST_MOVE_I T>::type* =0)
|
||||||
|
) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
//If T is not an array type, U derives from T
|
||||||
|
//and T has no virtual destructor, then you have a problem
|
||||||
|
BOOST_STATIC_ASSERT(( !::boost::move_upmu::missing_virtual_destructor<default_delete, U>::value ));
|
||||||
|
}
|
||||||
|
|
||||||
|
//! <b>Effects</b>: Constructs a default_delete object from another <tt>default_delete<U></tt> object.
|
||||||
|
//!
|
||||||
|
//! <b>Remarks</b>: This constructor shall not participate in overload resolution unless:
|
||||||
|
//! - If T is not an array type and U* is implicitly convertible to T*.
|
||||||
|
//! - If T is an array type and U* is a more CV qualified pointer to remove_extent<T>::type.
|
||||||
|
template <class U>
|
||||||
|
BOOST_MOVE_DOC1ST(default_delete&,
|
||||||
|
typename bmupd::enable_def_del<U BOOST_MOVE_I T BOOST_MOVE_I default_delete &>::type)
|
||||||
|
operator=(const default_delete<U>&) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
//If T is not an array type, U derives from T
|
||||||
|
//and T has no virtual destructor, then you have a problem
|
||||||
|
BOOST_STATIC_ASSERT(( !::boost::move_upmu::missing_virtual_destructor<default_delete, U>::value ));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! <b>Effects</b>: if T is not an array type, calls <tt>delete</tt> on static_cast<T*>(ptr),
|
||||||
|
//! otherwise calls <tt>delete[]</tt> on static_cast<remove_extent<T>::type*>(ptr).
|
||||||
|
//!
|
||||||
|
//! <b>Remarks</b>: If U is an incomplete type, the program is ill-formed.
|
||||||
|
//! This operator shall not participate in overload resolution unless:
|
||||||
|
//! - T is not an array type and U* is convertible to T*, OR
|
||||||
|
//! - T is an array type, and remove_cv<U>::type is the same type as
|
||||||
|
//! remove_cv<remove_extent<T>::type>::type and U* is convertible to remove_extent<T>::type*.
|
||||||
|
template <class U>
|
||||||
|
BOOST_MOVE_DOC1ST(void, typename bmupd::enable_defdel_call<U BOOST_MOVE_I T BOOST_MOVE_I void>::type)
|
||||||
|
operator()(U* ptr) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
//U must be a complete type
|
||||||
|
BOOST_STATIC_ASSERT(sizeof(U) > 0);
|
||||||
|
//If T is not an array type, U derives from T
|
||||||
|
//and T has no virtual destructor, then you have a problem
|
||||||
|
BOOST_STATIC_ASSERT(( !::boost::move_upmu::missing_virtual_destructor<default_delete, U>::value ));
|
||||||
|
element_type * const p = static_cast<element_type*>(ptr);
|
||||||
|
bmupmu::is_array<T>::value ? delete [] p : delete p;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! <b>Effects</b>: Same as <tt>(*this)(static_cast<element_type*>(nullptr))</tt>.
|
||||||
|
//!
|
||||||
|
void operator()(BOOST_MOVE_DOC0PTR(bmupd::nullptr_type)) const BOOST_NOEXCEPT
|
||||||
|
{ BOOST_STATIC_ASSERT(sizeof(element_type) > 0); }
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace movelib {
|
||||||
|
} //namespace boost{
|
||||||
|
|
||||||
|
#include <boost/move/detail/config_end.hpp>
|
||||||
|
|
||||||
|
#endif //#ifndef BOOST_MOVE_DEFAULT_DELETE_HPP_INCLUDED
|
@@ -10,15 +10,7 @@
|
|||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
|
||||||
#define BOOST_MOVE_CRT_SECURE_NO_DEPRECATE
|
|
||||||
#define _CRT_SECURE_NO_DEPRECATE
|
|
||||||
#endif
|
|
||||||
#ifndef _SCL_SECURE_NO_WARNINGS
|
|
||||||
#define BOOST_MOVE_SCL_SECURE_NO_WARNINGS
|
|
||||||
#define _SCL_SECURE_NO_WARNINGS
|
|
||||||
#endif
|
|
||||||
#pragma warning (push)
|
#pragma warning (push)
|
||||||
#pragma warning (disable : 4996) // "function": was declared deprecated
|
#pragma warning (disable : 4996) // "function": was declared deprecated (_CRT_SECURE_NO_DEPRECATE/_SCL_SECURE_NO_WARNINGS)
|
||||||
#pragma warning (disable : 4675) // "function": resolved overload was found by argument-dependent lookup
|
#pragma warning (disable : 4675) // "function": resolved overload was found by argument-dependent lookup
|
||||||
#endif
|
#endif
|
||||||
|
@@ -4,17 +4,9 @@
|
|||||||
// Software License, Version 1.0. (See accompanying file
|
// Software License, Version 1.0. (See accompanying file
|
||||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
// See http://www.boost.org/libs/container for documentation.
|
// See http://www.boost.org/libs/move for documentation.
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
#if defined BOOST_MSVC
|
#if defined BOOST_MSVC
|
||||||
#pragma warning (pop)
|
#pragma warning (pop)
|
||||||
#ifdef BOOST_MOVE_CRT_SECURE_NO_DEPRECATE
|
|
||||||
#undef BOOST_MOVE_CRT_SECURE_NO_DEPRECATE
|
|
||||||
#undef _CRT_SECURE_NO_DEPRECATE
|
|
||||||
#endif
|
|
||||||
#ifdef BOOST_MOVE_SCL_SECURE_NO_WARNINGS
|
|
||||||
#undef BOOST_MOVE_SCL_SECURE_NO_WARNINGS
|
|
||||||
#undef _SCL_SECURE_NO_WARNINGS
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -264,6 +264,40 @@ struct remove_extent<T[N]>
|
|||||||
typedef T type;
|
typedef T type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// extent
|
||||||
|
//////////////////////////////////////
|
||||||
|
|
||||||
|
template<class T, unsigned N = 0>
|
||||||
|
struct extent
|
||||||
|
{
|
||||||
|
static const std::size_t value = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct extent<T[], 0>
|
||||||
|
{
|
||||||
|
static const std::size_t value = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, unsigned N>
|
||||||
|
struct extent<T[], N>
|
||||||
|
{
|
||||||
|
static const std::size_t value = extent<T, N-1>::value;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, std::size_t N>
|
||||||
|
struct extent<T[N], 0>
|
||||||
|
{
|
||||||
|
static const std::size_t value = N;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, std::size_t I, unsigned N>
|
||||||
|
struct extent<T[I], N>
|
||||||
|
{
|
||||||
|
static const std::size_t value = extent<T, N-1>::value;
|
||||||
|
};
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// element_pointer
|
// element_pointer
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
@@ -313,6 +347,15 @@ struct add_lvalue_reference<const volatile void>
|
|||||||
typedef const volatile void type;
|
typedef const volatile void type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct add_const_lvalue_reference
|
||||||
|
{
|
||||||
|
typedef typename remove_reference<T>::type t_unreferenced;
|
||||||
|
typedef typename add_const<t_unreferenced>::type t_unreferenced_const;
|
||||||
|
typedef typename add_lvalue_reference
|
||||||
|
<t_unreferenced_const>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// is_same
|
// is_same
|
||||||
@@ -483,7 +526,8 @@ struct pointer_type_imp<T, D, false>
|
|||||||
template <class T, class D>
|
template <class T, class D>
|
||||||
struct pointer_type
|
struct pointer_type
|
||||||
{
|
{
|
||||||
typedef typename pointer_type_imp<T, typename remove_reference<D>::type>::type type;
|
typedef typename pointer_type_imp
|
||||||
|
<typename remove_extent<T>::type, typename remove_reference<D>::type>::type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
@@ -517,7 +561,7 @@ class is_convertible
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// is_unary_or_binary_function
|
// is_unary_function
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
#if defined(BOOST_MSVC) || defined(__BORLANDC_)
|
#if defined(BOOST_MSVC) || defined(__BORLANDC_)
|
||||||
#define BOOST_MOVE_TT_DECL __cdecl
|
#define BOOST_MOVE_TT_DECL __cdecl
|
||||||
@@ -530,120 +574,86 @@ class is_convertible
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_unary_or_binary_function_impl
|
struct is_unary_function_impl
|
||||||
{ static const bool value = false; };
|
{ static const bool value = false; };
|
||||||
|
|
||||||
// avoid duplicate definitions of is_unary_or_binary_function_impl
|
// avoid duplicate definitions of is_unary_function_impl
|
||||||
#ifndef BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
#ifndef BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
struct is_unary_or_binary_function_impl<R (*)()>
|
struct is_unary_function_impl<R (*)()>
|
||||||
{ static const bool value = true; };
|
{ static const bool value = true; };
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
struct is_unary_or_binary_function_impl<R (*)(...)>
|
struct is_unary_function_impl<R (*)(...)>
|
||||||
{ static const bool value = true; };
|
{ static const bool value = true; };
|
||||||
|
|
||||||
#else // BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
#else // BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
struct is_unary_or_binary_function_impl<R (__stdcall*)()>
|
struct is_unary_function_impl<R (__stdcall*)()>
|
||||||
{ static const bool value = true; };
|
{ static const bool value = true; };
|
||||||
|
|
||||||
#ifndef _MANAGED
|
#ifndef _MANAGED
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
struct is_unary_or_binary_function_impl<R (__fastcall*)()>
|
struct is_unary_function_impl<R (__fastcall*)()>
|
||||||
{ static const bool value = true; };
|
{ static const bool value = true; };
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
struct is_unary_or_binary_function_impl<R (__cdecl*)()>
|
struct is_unary_function_impl<R (__cdecl*)()>
|
||||||
{ static const bool value = true; };
|
{ static const bool value = true; };
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
struct is_unary_or_binary_function_impl<R (__cdecl*)(...)>
|
struct is_unary_function_impl<R (__cdecl*)(...)>
|
||||||
{ static const bool value = true; };
|
{ static const bool value = true; };
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// avoid duplicate definitions of is_unary_or_binary_function_impl
|
// avoid duplicate definitions of is_unary_function_impl
|
||||||
#ifndef BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
#ifndef BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
|
||||||
template <typename R, class T0>
|
template <typename R, class T0>
|
||||||
struct is_unary_or_binary_function_impl<R (*)(T0)>
|
struct is_unary_function_impl<R (*)(T0)>
|
||||||
{ static const bool value = true; };
|
{ static const bool value = true; };
|
||||||
|
|
||||||
template <typename R, class T0>
|
template <typename R, class T0>
|
||||||
struct is_unary_or_binary_function_impl<R (*)(T0...)>
|
struct is_unary_function_impl<R (*)(T0...)>
|
||||||
{ static const bool value = true; };
|
{ static const bool value = true; };
|
||||||
|
|
||||||
#else // BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
#else // BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
|
||||||
template <typename R, class T0>
|
template <typename R, class T0>
|
||||||
struct is_unary_or_binary_function_impl<R (__stdcall*)(T0)>
|
struct is_unary_function_impl<R (__stdcall*)(T0)>
|
||||||
{ static const bool value = true; };
|
{ static const bool value = true; };
|
||||||
|
|
||||||
#ifndef _MANAGED
|
#ifndef _MANAGED
|
||||||
|
|
||||||
template <typename R, class T0>
|
template <typename R, class T0>
|
||||||
struct is_unary_or_binary_function_impl<R (__fastcall*)(T0)>
|
struct is_unary_function_impl<R (__fastcall*)(T0)>
|
||||||
{ static const bool value = true; };
|
{ static const bool value = true; };
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <typename R, class T0>
|
template <typename R, class T0>
|
||||||
struct is_unary_or_binary_function_impl<R (__cdecl*)(T0)>
|
struct is_unary_function_impl<R (__cdecl*)(T0)>
|
||||||
{ static const bool value = true; };
|
{ static const bool value = true; };
|
||||||
|
|
||||||
template <typename R, class T0>
|
template <typename R, class T0>
|
||||||
struct is_unary_or_binary_function_impl<R (__cdecl*)(T0...)>
|
struct is_unary_function_impl<R (__cdecl*)(T0...)>
|
||||||
{ static const bool value = true; };
|
{ static const bool value = true; };
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// avoid duplicate definitions of is_unary_or_binary_function_impl
|
|
||||||
#ifndef BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
|
||||||
|
|
||||||
template <typename R, class T0, class T1>
|
|
||||||
struct is_unary_or_binary_function_impl<R (*)(T0, T1)>
|
|
||||||
{ static const bool value = true; };
|
|
||||||
|
|
||||||
template <typename R, class T0, class T1>
|
|
||||||
struct is_unary_or_binary_function_impl<R (*)(T0, T1...)>
|
|
||||||
{ static const bool value = true; };
|
|
||||||
|
|
||||||
#else // BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
|
||||||
|
|
||||||
template <typename R, class T0, class T1>
|
|
||||||
struct is_unary_or_binary_function_impl<R (__stdcall*)(T0, T1)>
|
|
||||||
{ static const bool value = true; };
|
|
||||||
|
|
||||||
#ifndef _MANAGED
|
|
||||||
|
|
||||||
template <typename R, class T0, class T1>
|
|
||||||
struct is_unary_or_binary_function_impl<R (__fastcall*)(T0, T1)>
|
|
||||||
{ static const bool value = true; };
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <typename R, class T0, class T1>
|
|
||||||
struct is_unary_or_binary_function_impl<R (__cdecl*)(T0, T1)>
|
|
||||||
{ static const bool value = true; };
|
|
||||||
|
|
||||||
template <typename R, class T0, class T1>
|
|
||||||
struct is_unary_or_binary_function_impl<R (__cdecl*)(T0, T1...)>
|
|
||||||
{ static const bool value = true; };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_unary_or_binary_function_impl<T&>
|
struct is_unary_function_impl<T&>
|
||||||
{ static const bool value = false; };
|
{ static const bool value = false; };
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct is_unary_or_binary_function
|
struct is_unary_function
|
||||||
{ static const bool value = is_unary_or_binary_function_impl<T>::value; };
|
{ static const bool value = is_unary_function_impl<T>::value; };
|
||||||
|
|
||||||
} //namespace move_detail {
|
} //namespace move_detail {
|
||||||
} //namespace boost {
|
} //namespace boost {
|
||||||
|
583
include/boost/move/detail/unique_ptr_meta_utils.hpp
Normal file
583
include/boost/move/detail/unique_ptr_meta_utils.hpp
Normal file
@@ -0,0 +1,583 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Ion Gaztanaga 2012-2012.
|
||||||
|
// 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/libs/move for documentation.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BOOST_MOVE_UNIQUE_PTR_DETAIL_META_UTILS_HPP
|
||||||
|
#define BOOST_MOVE_UNIQUE_PTR_DETAIL_META_UTILS_HPP
|
||||||
|
|
||||||
|
#include <cstddef> //for std::size_t
|
||||||
|
|
||||||
|
//Small meta-typetraits to support move
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
|
||||||
|
namespace movelib {
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
struct default_delete;
|
||||||
|
|
||||||
|
} //namespace movelib {
|
||||||
|
|
||||||
|
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
|
//Forward declare boost::rv
|
||||||
|
template <class T> class rv;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace move_upmu {
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// nat
|
||||||
|
//////////////////////////////////////
|
||||||
|
struct nat{};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// natify
|
||||||
|
//////////////////////////////////////
|
||||||
|
template <class T> struct natify{};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// if_c
|
||||||
|
//////////////////////////////////////
|
||||||
|
template<bool C, typename T1, typename T2>
|
||||||
|
struct if_c
|
||||||
|
{
|
||||||
|
typedef T1 type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T1, typename T2>
|
||||||
|
struct if_c<false,T1,T2>
|
||||||
|
{
|
||||||
|
typedef T2 type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// if_
|
||||||
|
//////////////////////////////////////
|
||||||
|
template<typename T1, typename T2, typename T3>
|
||||||
|
struct if_ : if_c<0 != T1::value, T2, T3>
|
||||||
|
{};
|
||||||
|
|
||||||
|
//enable_if_
|
||||||
|
template <bool B, class T = nat>
|
||||||
|
struct enable_if_c
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// enable_if_c
|
||||||
|
//////////////////////////////////////
|
||||||
|
template <class T>
|
||||||
|
struct enable_if_c<false, T> {};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// enable_if
|
||||||
|
//////////////////////////////////////
|
||||||
|
template <class Cond, class T = nat>
|
||||||
|
struct enable_if : public enable_if_c<Cond::value, T> {};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// remove_reference
|
||||||
|
//////////////////////////////////////
|
||||||
|
template<class T>
|
||||||
|
struct remove_reference
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct remove_reference<T&>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct remove_reference<T&&>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct remove_reference< rv<T> >
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct remove_reference< rv<T> &>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct remove_reference< const rv<T> &>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// remove_const
|
||||||
|
//////////////////////////////////////
|
||||||
|
template< class T >
|
||||||
|
struct remove_const
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< class T >
|
||||||
|
struct remove_const<const T>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// remove_volatile
|
||||||
|
//////////////////////////////////////
|
||||||
|
template< class T >
|
||||||
|
struct remove_volatile
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< class T >
|
||||||
|
struct remove_volatile<volatile T>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// remove_cv
|
||||||
|
//////////////////////////////////////
|
||||||
|
template< class T >
|
||||||
|
struct remove_cv
|
||||||
|
{
|
||||||
|
typedef typename remove_volatile
|
||||||
|
<typename remove_const<T>::type>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// remove_extent
|
||||||
|
//////////////////////////////////////
|
||||||
|
template<class T>
|
||||||
|
struct remove_extent
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct remove_extent<T[]>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, std::size_t N>
|
||||||
|
struct remove_extent<T[N]>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// extent
|
||||||
|
//////////////////////////////////////
|
||||||
|
|
||||||
|
template<class T, unsigned N = 0>
|
||||||
|
struct extent
|
||||||
|
{
|
||||||
|
static const std::size_t value = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct extent<T[], 0>
|
||||||
|
{
|
||||||
|
static const std::size_t value = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, unsigned N>
|
||||||
|
struct extent<T[], N>
|
||||||
|
{
|
||||||
|
static const std::size_t value = extent<T, N-1>::value;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, std::size_t N>
|
||||||
|
struct extent<T[N], 0>
|
||||||
|
{
|
||||||
|
static const std::size_t value = N;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, std::size_t I, unsigned N>
|
||||||
|
struct extent<T[I], N>
|
||||||
|
{
|
||||||
|
static const std::size_t value = extent<T, N-1>::value;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// add_lvalue_reference
|
||||||
|
//////////////////////////////////////
|
||||||
|
template<class T>
|
||||||
|
struct add_lvalue_reference
|
||||||
|
{
|
||||||
|
typedef T& type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct add_lvalue_reference<T&>
|
||||||
|
{
|
||||||
|
typedef T& type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct add_lvalue_reference<void>
|
||||||
|
{
|
||||||
|
typedef void type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct add_lvalue_reference<const void>
|
||||||
|
{
|
||||||
|
typedef const void type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct add_lvalue_reference<volatile void>
|
||||||
|
{
|
||||||
|
typedef volatile void type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct add_lvalue_reference<const volatile void>
|
||||||
|
{
|
||||||
|
typedef const volatile void type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct add_const_lvalue_reference
|
||||||
|
{
|
||||||
|
typedef typename remove_reference<T>::type t_unreferenced;
|
||||||
|
typedef const t_unreferenced t_unreferenced_const;
|
||||||
|
typedef typename add_lvalue_reference
|
||||||
|
<t_unreferenced_const>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// is_same
|
||||||
|
//////////////////////////////////////
|
||||||
|
template<class T, class U>
|
||||||
|
struct is_same
|
||||||
|
{
|
||||||
|
static const bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct is_same<T, T>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// is_pointer
|
||||||
|
//////////////////////////////////////
|
||||||
|
template< class T >
|
||||||
|
struct is_pointer
|
||||||
|
{
|
||||||
|
static const bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< class T >
|
||||||
|
struct is_pointer<T*>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// is_reference
|
||||||
|
//////////////////////////////////////
|
||||||
|
template< class T >
|
||||||
|
struct is_reference
|
||||||
|
{
|
||||||
|
static const bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< class T >
|
||||||
|
struct is_reference<T&>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
|
|
||||||
|
template< class T >
|
||||||
|
struct is_reference<T&&>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// is_lvalue_reference
|
||||||
|
//////////////////////////////////////
|
||||||
|
template<class T>
|
||||||
|
struct is_lvalue_reference
|
||||||
|
{
|
||||||
|
static const bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct is_lvalue_reference<T&>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// is_array
|
||||||
|
//////////////////////////////////////
|
||||||
|
template<class T>
|
||||||
|
struct is_array
|
||||||
|
{
|
||||||
|
static const bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct is_array<T[]>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, std::size_t N>
|
||||||
|
struct is_array<T[N]>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// has_pointer_type
|
||||||
|
//////////////////////////////////////
|
||||||
|
template <class T>
|
||||||
|
struct has_pointer_type
|
||||||
|
{
|
||||||
|
struct two { char c[2]; };
|
||||||
|
template <class U> static two test(...);
|
||||||
|
template <class U> static char test(typename U::pointer* = 0);
|
||||||
|
static const bool value = sizeof(test<T>(0)) == 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// pointer_type
|
||||||
|
//////////////////////////////////////
|
||||||
|
template <class T, class D, bool = has_pointer_type<D>::value>
|
||||||
|
struct pointer_type_imp
|
||||||
|
{
|
||||||
|
typedef typename D::pointer type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T, class D>
|
||||||
|
struct pointer_type_imp<T, D, false>
|
||||||
|
{
|
||||||
|
typedef typename remove_extent<T>::type* type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T, class D>
|
||||||
|
struct pointer_type
|
||||||
|
{
|
||||||
|
typedef typename pointer_type_imp
|
||||||
|
<typename remove_extent<T>::type, typename remove_reference<D>::type>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// is_convertible
|
||||||
|
//////////////////////////////////////
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||||
|
|
||||||
|
//use intrinsic since in MSVC
|
||||||
|
//overaligned types can't go through ellipsis
|
||||||
|
template <class T, class U>
|
||||||
|
struct is_convertible
|
||||||
|
{
|
||||||
|
static const bool value = __is_convertible_to(T, U);
|
||||||
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
class is_convertible
|
||||||
|
{
|
||||||
|
typedef typename add_lvalue_reference<T>::type t_reference;
|
||||||
|
typedef char true_t;
|
||||||
|
class false_t { char dummy[2]; };
|
||||||
|
static false_t dispatch(...);
|
||||||
|
static true_t dispatch(U);
|
||||||
|
static t_reference trigger();
|
||||||
|
public:
|
||||||
|
static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// is_unary_function
|
||||||
|
//////////////////////////////////////
|
||||||
|
#if defined(BOOST_MSVC) || defined(__BORLANDC_)
|
||||||
|
#define BOOST_MOVE_TT_DECL __cdecl
|
||||||
|
#else
|
||||||
|
#define BOOST_MOVE_TT_DECL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_EXTENSIONS) && !defined(__BORLAND__) && !defined(_WIN64) && !defined(_M_ARM) && !defined(UNDER_CE)
|
||||||
|
#define BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct is_unary_function_impl
|
||||||
|
{ static const bool value = false; };
|
||||||
|
|
||||||
|
// avoid duplicate definitions of is_unary_function_impl
|
||||||
|
#ifndef BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
|
||||||
|
template <typename R>
|
||||||
|
struct is_unary_function_impl<R (*)()>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
template <typename R>
|
||||||
|
struct is_unary_function_impl<R (*)(...)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#else // BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
|
||||||
|
template <typename R>
|
||||||
|
struct is_unary_function_impl<R (__stdcall*)()>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#ifndef _MANAGED
|
||||||
|
|
||||||
|
template <typename R>
|
||||||
|
struct is_unary_function_impl<R (__fastcall*)()>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename R>
|
||||||
|
struct is_unary_function_impl<R (__cdecl*)()>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
template <typename R>
|
||||||
|
struct is_unary_function_impl<R (__cdecl*)(...)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// avoid duplicate definitions of is_unary_function_impl
|
||||||
|
#ifndef BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
|
||||||
|
template <typename R, class T0>
|
||||||
|
struct is_unary_function_impl<R (*)(T0)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
template <typename R, class T0>
|
||||||
|
struct is_unary_function_impl<R (*)(T0...)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#else // BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
|
||||||
|
template <typename R, class T0>
|
||||||
|
struct is_unary_function_impl<R (__stdcall*)(T0)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#ifndef _MANAGED
|
||||||
|
|
||||||
|
template <typename R, class T0>
|
||||||
|
struct is_unary_function_impl<R (__fastcall*)(T0)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename R, class T0>
|
||||||
|
struct is_unary_function_impl<R (__cdecl*)(T0)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
template <typename R, class T0>
|
||||||
|
struct is_unary_function_impl<R (__cdecl*)(T0...)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct is_unary_function_impl<T&>
|
||||||
|
{ static const bool value = false; };
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct is_unary_function
|
||||||
|
{ static const bool value = is_unary_function_impl<T>::value; };
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// has_virtual_destructor
|
||||||
|
//////////////////////////////////////
|
||||||
|
#if (defined(BOOST_MSVC) && defined(BOOST_MSVC_FULL_VER) && (BOOST_MSVC_FULL_VER >=140050215))\
|
||||||
|
|| (defined(BOOST_INTEL) && defined(_MSC_VER) && (_MSC_VER >= 1500))
|
||||||
|
# define BOOST_MOVEUP_HAS_VIRTUAL_DESTRUCTOR(T) __has_virtual_destructor(T)
|
||||||
|
#elif defined(BOOST_CLANG) && defined(__has_feature)
|
||||||
|
# if __has_feature(has_virtual_destructor)
|
||||||
|
# define BOOST_MOVEUP_HAS_VIRTUAL_DESTRUCTOR(T) __has_virtual_destructor(T)
|
||||||
|
# endif
|
||||||
|
#elif defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3) && !defined(__GCCXML__))) && !defined(BOOST_CLANG)
|
||||||
|
# define BOOST_MOVEUP_HAS_VIRTUAL_DESTRUCTOR(T) __has_virtual_destructor(T)
|
||||||
|
#elif defined(__ghs__) && (__GHS_VERSION_NUMBER >= 600)
|
||||||
|
# define BOOST_MOVEUP_HAS_VIRTUAL_DESTRUCTOR(T) __has_virtual_destructor(T)
|
||||||
|
#elif defined(__CODEGEARC__)
|
||||||
|
# define BOOST_MOVEUP_HAS_VIRTUAL_DESTRUCTOR(T) __has_virtual_destructor(T)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef BOOST_MOVEUP_HAS_VIRTUAL_DESTRUCTOR
|
||||||
|
template<class T>
|
||||||
|
struct has_virtual_destructor{ static const bool value = BOOST_MOVEUP_HAS_VIRTUAL_DESTRUCTOR(T); };
|
||||||
|
#else
|
||||||
|
//If no intrinsic is available you trust the programmer knows what is doing
|
||||||
|
template<class T>
|
||||||
|
struct has_virtual_destructor{ static const bool value = true; };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// missing_virtual_destructor
|
||||||
|
//////////////////////////////////////
|
||||||
|
|
||||||
|
template< class T, class U
|
||||||
|
, bool enable = is_convertible< U*, T*>::value &&
|
||||||
|
!is_array<T>::value &&
|
||||||
|
!is_same<typename remove_cv<T>::type, void>::value &&
|
||||||
|
!is_same<typename remove_cv<U>::type, typename remove_cv<T>::type>::value
|
||||||
|
>
|
||||||
|
struct missing_virtual_destructor_default_delete
|
||||||
|
{ static const bool value = !has_virtual_destructor<T>::value; };
|
||||||
|
|
||||||
|
template<class T, class U>
|
||||||
|
struct missing_virtual_destructor_default_delete<T, U, false>
|
||||||
|
{ static const bool value = false; };
|
||||||
|
|
||||||
|
template<class Deleter, class U>
|
||||||
|
struct missing_virtual_destructor
|
||||||
|
{ static const bool value = false; };
|
||||||
|
|
||||||
|
template<class T, class U>
|
||||||
|
struct missing_virtual_destructor< ::boost::movelib::default_delete<T>, U >
|
||||||
|
: missing_virtual_destructor_default_delete<T, U>
|
||||||
|
{};
|
||||||
|
|
||||||
|
} //namespace move_upmu {
|
||||||
|
} //namespace boost {
|
||||||
|
|
||||||
|
#endif //#ifndef BOOST_MOVE_UNIQUE_PTR_DETAIL_META_UTILS_HPP
|
@@ -20,6 +20,10 @@
|
|||||||
//Macros for documentation purposes. For code, expands to the argument
|
//Macros for documentation purposes. For code, expands to the argument
|
||||||
#define BOOST_MOVE_IMPDEF(TYPE) TYPE
|
#define BOOST_MOVE_IMPDEF(TYPE) TYPE
|
||||||
#define BOOST_MOVE_SEEDOC(TYPE) TYPE
|
#define BOOST_MOVE_SEEDOC(TYPE) TYPE
|
||||||
|
#define BOOST_MOVE_DOC0PTR(TYPE) TYPE
|
||||||
|
#define BOOST_MOVE_DOC1ST(TYPE1, TYPE2) TYPE2
|
||||||
|
#define BOOST_MOVE_I ,
|
||||||
|
#define BOOST_MOVE_DOCIGN(T1) T1
|
||||||
|
|
||||||
#include <boost/intrusive/detail/config_end.hpp>
|
#include <boost/intrusive/detail/config_end.hpp>
|
||||||
|
|
||||||
|
@@ -71,13 +71,9 @@ namespace movelib {
|
|||||||
//!
|
//!
|
||||||
//! <b>Returns</b>: <tt>unique_ptr<T>(new T(std::forward<Args>(args)...))</tt>.
|
//! <b>Returns</b>: <tt>unique_ptr<T>(new T(std::forward<Args>(args)...))</tt>.
|
||||||
template<class T, class... Args>
|
template<class T, class... Args>
|
||||||
inline
|
inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
|
||||||
#if defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
typename ::boost::move_detail::unique_ptr_if<T>::t_is_not_array)
|
||||||
unique_ptr<T>
|
make_unique(BOOST_FWD_REF(Args)... args)
|
||||||
#else
|
|
||||||
typename ::boost::move_detail::unique_ptr_if<T>::t_is_not_array
|
|
||||||
#endif
|
|
||||||
make_unique(BOOST_FWD_REF(Args)... args)
|
|
||||||
{ return unique_ptr<T>(new T(::boost::forward<Args>(args)...)); }
|
{ return unique_ptr<T>(new T(::boost::forward<Args>(args)...)); }
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -109,35 +105,51 @@ inline
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//! <b>Remarks</b>: This function shall not participate in overload resolution unless T is not an array.
|
||||||
|
//!
|
||||||
|
//! <b>Returns</b>: <tt>unique_ptr<T>(new T)</tt> (default initialization)
|
||||||
|
template<class T>
|
||||||
|
inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
|
||||||
|
typename ::boost::move_detail::unique_ptr_if<T>::t_is_not_array)
|
||||||
|
make_unique_definit()
|
||||||
|
{
|
||||||
|
return unique_ptr<T>(new T);
|
||||||
|
}
|
||||||
|
|
||||||
//! <b>Remarks</b>: This function shall not participate in overload resolution unless T is an array of
|
//! <b>Remarks</b>: This function shall not participate in overload resolution unless T is an array of
|
||||||
//! unknown bound.
|
//! unknown bound.
|
||||||
//!
|
//!
|
||||||
//! <b>Returns</b>: <tt>unique_ptr<T>(new remove_extent_t<T>[n]())</tt>.
|
//! <b>Returns</b>: <tt>unique_ptr<T>(new remove_extent_t<T>[n]())</tt> (value initialization)
|
||||||
template<class T>
|
template<class T>
|
||||||
inline
|
inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
|
||||||
#if defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
typename ::boost::move_detail::unique_ptr_if<T>::t_is_array_of_unknown_bound)
|
||||||
unique_ptr<T>
|
make_unique(std::size_t n)
|
||||||
#else
|
|
||||||
typename ::boost::move_detail::unique_ptr_if<T>::t_is_array_of_unknown_bound
|
|
||||||
#endif
|
|
||||||
make_unique(std::size_t n)
|
|
||||||
{
|
{
|
||||||
typedef typename ::boost::move_detail::remove_extent<T>::type U;
|
typedef typename ::boost::move_detail::remove_extent<T>::type U;
|
||||||
return unique_ptr<T>(new U[n]());
|
return unique_ptr<T>(new U[n]());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_MOVE_DOXYGEN_INVOKED) || !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
|
//! <b>Remarks</b>: This function shall not participate in overload resolution unless T is an array of
|
||||||
|
//! unknown bound.
|
||||||
|
//!
|
||||||
|
//! <b>Returns</b>: <tt>unique_ptr<T>(new remove_extent_t<T>[n])</tt> (default initialization)
|
||||||
|
template<class T>
|
||||||
|
inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
|
||||||
|
typename ::boost::move_detail::unique_ptr_if<T>::t_is_array_of_unknown_bound)
|
||||||
|
make_unique_definit(std::size_t n)
|
||||||
|
{
|
||||||
|
typedef typename ::boost::move_detail::remove_extent<T>::type U;
|
||||||
|
return unique_ptr<T>(new U[n]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
|
||||||
|
|
||||||
//! <b>Remarks</b>: This function shall not participate in overload resolution unless T is
|
//! <b>Remarks</b>: This function shall not participate in overload resolution unless T is
|
||||||
//! an array of known bound.
|
//! an array of known bound.
|
||||||
template<class T, class... Args>
|
template<class T, class... Args>
|
||||||
#if defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
inline BOOST_MOVE_DOC1ST(unspecified,
|
||||||
unspecified
|
typename ::boost::move_detail::unique_ptr_if<T>::t_is_array_of_known_bound)
|
||||||
#else
|
make_unique(BOOST_FWD_REF(Args) ...) = delete;
|
||||||
typename ::boost::move_detail::unique_ptr_if<T>::t_is_array_of_known_bound
|
|
||||||
#endif
|
|
||||||
make_unique(BOOST_FWD_REF(Args) ...) = delete;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} //namespace movelib {
|
} //namespace movelib {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -164,8 +164,9 @@
|
|||||||
|
|
||||||
#if defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
#if defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||||
//! This function provides a way to convert a reference into a rvalue reference
|
//! This function provides a way to convert a reference into a rvalue reference
|
||||||
//! in compilers with rvalue references. For other compilers converts T & into
|
//! in compilers with rvalue references. For other compilers if `T` is Boost.Move
|
||||||
//! <i>::boost::rv<T> &</i> so that move emulation is activated.
|
//! enabled type then it converts `T&` into <tt>::boost::rv<T> &</tt> so that
|
||||||
|
//! move emulation is activated, else it returns `T &`.
|
||||||
template <class T>
|
template <class T>
|
||||||
rvalue_reference move(input_reference) noexcept;
|
rvalue_reference move(input_reference) noexcept;
|
||||||
|
|
||||||
|
@@ -71,11 +71,35 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique_ptr_default_deleter_
|
|||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique_ptr_test", "unique_ptr_test.vcproj", "{C57C28A3-4FE0-6208-BF87-A2B61D3A7671}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique_ptr_functions_test", "unique_ptr_functions.vcproj", "{C57C25A3-4620-FE08-F8B7-AB673D762B60}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique_ptr_functions_test", "unique_ptr_functions.vcproj", "{C57C25A3-4620-FE08-F8B7-AB673D762B60}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique_ptr_assign_test", "unique_ptr_assign_test.vcproj", "{C57C28A3-4FE0-6208-BF87-B2B61D3A7674}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique_ptr_ctordtor_test", "unique_ptr_ctordtor_test.vcproj", "{C57C28A3-4FE0-6208-BF87-B2B61D3A7676}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique_ptr_modifiers_test", "unique_ptr_modifiers_test.vcproj", "{C57C28A3-4FE0-6208-BF87-B2B61D3A7673}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique_ptr_movector_test", "unique_ptr_movector_test.vcproj", "{C57C28A3-4FE0-6208-BF87-B2B61D3A7672}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique_ptr_nullptr_test", "unique_ptr_nullptr_test.vcproj", "{C57C28A3-4FE0-6208-BF87-B2B61D3A7671}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique_ptr_observers_test", "unique_ptr_observers_test.vcproj", "{C57C28A3-4FE0-6208-BF87-B2B61D3A7670}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique_ptr_types_test", "unique_ptr_types_test.vcproj", "{C57C28A3-4FE0-6208-BF87-B2B61D3A7675}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
@@ -159,20 +183,45 @@ Global
|
|||||||
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.Debug.Build.0 = Debug|Win32
|
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.Debug.Build.0 = Debug|Win32
|
||||||
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.Release.ActiveCfg = Release|Win32
|
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.Release.ActiveCfg = Release|Win32
|
||||||
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.Release.Build.0 = Release|Win32
|
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.Release.Build.0 = Release|Win32
|
||||||
{C57C28A3-4FE0-6208-BF87-A2B61D3A7671}.Debug.ActiveCfg = Debug|Win32
|
|
||||||
{C57C28A3-4FE0-6208-BF87-A2B61D3A7671}.Debug.Build.0 = Debug|Win32
|
|
||||||
{C57C28A3-4FE0-6208-BF87-A2B61D3A7671}.Release.ActiveCfg = Release|Win32
|
|
||||||
{C57C28A3-4FE0-6208-BF87-A2B61D3A7671}.Release.Build.0 = Release|Win32
|
|
||||||
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.Debug.ActiveCfg = Debug|Win32
|
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.Debug.ActiveCfg = Debug|Win32
|
||||||
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.Debug.Build.0 = Debug|Win32
|
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.Debug.Build.0 = Debug|Win32
|
||||||
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.Release.ActiveCfg = Release|Win32
|
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.Release.ActiveCfg = Release|Win32
|
||||||
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.Release.Build.0 = Release|Win32
|
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.Release.Build.0 = Release|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7674}.Debug.ActiveCfg = Debug|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7674}.Debug.Build.0 = Debug|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7674}.Release.ActiveCfg = Release|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7674}.Release.Build.0 = Release|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7676}.Debug.ActiveCfg = Debug|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7676}.Debug.Build.0 = Debug|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7676}.Release.ActiveCfg = Release|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7676}.Release.Build.0 = Release|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7673}.Debug.ActiveCfg = Debug|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7673}.Debug.Build.0 = Debug|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7673}.Release.ActiveCfg = Release|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7673}.Release.Build.0 = Release|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7672}.Debug.ActiveCfg = Debug|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7672}.Debug.Build.0 = Debug|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7672}.Release.ActiveCfg = Release|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7672}.Release.Build.0 = Release|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7671}.Debug.ActiveCfg = Debug|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7671}.Debug.Build.0 = Debug|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7671}.Release.ActiveCfg = Release|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7671}.Release.Build.0 = Release|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7670}.Debug.ActiveCfg = Debug|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7670}.Debug.Build.0 = Debug|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7670}.Release.ActiveCfg = Release|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7670}.Release.Build.0 = Release|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7675}.Debug.ActiveCfg = Debug|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7675}.Debug.Build.0 = Debug|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7675}.Release.ActiveCfg = Release|Win32
|
||||||
|
{C57C28A3-4FE0-6208-BF87-B2B61D3A7675}.Release.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionItems) = postSolution
|
GlobalSection(SolutionItems) = postSolution
|
||||||
..\..\..\..\boost\move\algorithm.hpp = ..\..\..\..\boost\move\algorithm.hpp
|
..\..\..\..\boost\move\algorithm.hpp = ..\..\..\..\boost\move\algorithm.hpp
|
||||||
..\..\..\..\boost\move\detail\config_begin.hpp = ..\..\..\..\boost\move\detail\config_begin.hpp
|
..\..\..\..\boost\move\detail\config_begin.hpp = ..\..\..\..\boost\move\detail\config_begin.hpp
|
||||||
..\..\..\..\boost\move\detail\config_end.hpp = ..\..\..\..\boost\move\detail\config_end.hpp
|
..\..\..\..\boost\move\detail\config_end.hpp = ..\..\..\..\boost\move\detail\config_end.hpp
|
||||||
..\..\..\..\boost\move\core.hpp = ..\..\..\..\boost\move\core.hpp
|
..\..\..\..\boost\move\core.hpp = ..\..\..\..\boost\move\core.hpp
|
||||||
|
..\..\..\..\boost\move\default_delete.hpp = ..\..\..\..\boost\move\default_delete.hpp
|
||||||
..\..\..\..\boost\move\iterator.hpp = ..\..\..\..\boost\move\iterator.hpp
|
..\..\..\..\boost\move\iterator.hpp = ..\..\..\..\boost\move\iterator.hpp
|
||||||
..\..\doc\Jamfile.v2 = ..\..\doc\Jamfile.v2
|
..\..\doc\Jamfile.v2 = ..\..\doc\Jamfile.v2
|
||||||
..\..\..\..\boost\move\make_unique.hpp = ..\..\..\..\boost\move\make_unique.hpp
|
..\..\..\..\boost\move\make_unique.hpp = ..\..\..\..\boost\move\make_unique.hpp
|
||||||
@@ -182,8 +231,12 @@ Global
|
|||||||
..\..\..\..\boost\move\detail\move_helpers.hpp = ..\..\..\..\boost\move\detail\move_helpers.hpp
|
..\..\..\..\boost\move\detail\move_helpers.hpp = ..\..\..\..\boost\move\detail\move_helpers.hpp
|
||||||
..\..\..\..\boost\move\traits.hpp = ..\..\..\..\boost\move\traits.hpp
|
..\..\..\..\boost\move\traits.hpp = ..\..\..\..\boost\move\traits.hpp
|
||||||
..\..\..\..\boost\move\unique_ptr.hpp = ..\..\..\..\boost\move\unique_ptr.hpp
|
..\..\..\..\boost\move\unique_ptr.hpp = ..\..\..\..\boost\move\unique_ptr.hpp
|
||||||
|
..\..\..\..\boost\move\detail\unique_ptr_meta_utils.hpp = ..\..\..\..\boost\move\detail\unique_ptr_meta_utils.hpp
|
||||||
|
..\..\test\unique_ptr_test_utils_beg.hpp = ..\..\test\unique_ptr_test_utils_beg.hpp
|
||||||
|
..\..\test\unique_ptr_test_utils_end.hpp = ..\..\test\unique_ptr_test_utils_end.hpp
|
||||||
..\..\..\..\boost\move\utility.hpp = ..\..\..\..\boost\move\utility.hpp
|
..\..\..\..\boost\move\utility.hpp = ..\..\..\..\boost\move\utility.hpp
|
||||||
..\..\..\..\boost\move\utility_core.hpp = ..\..\..\..\boost\move\utility_core.hpp
|
..\..\..\..\boost\move\utility_core.hpp = ..\..\..\..\boost\move\utility_core.hpp
|
||||||
|
..\..\..\..\boost\move\detail\workaround.hpp = ..\..\..\..\boost\move\detail\workaround.hpp
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
135
proj/vc7ide/unique_ptr_assign_test.vcproj
Normal file
135
proj/vc7ide/unique_ptr_assign_test.vcproj
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="7.10"
|
||||||
|
Name="unique_ptr_assign_test"
|
||||||
|
ProjectGUID="{C57C28A3-4FE0-6208-BF87-B2B61D3A7674}"
|
||||||
|
Keyword="Win32Proj">
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"/>
|
||||||
|
</Platforms>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Debug"
|
||||||
|
IntermediateDirectory="Debug/unique_ptr_assign_test"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories="../../../.."
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
|
||||||
|
MinimalRebuild="TRUE"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
DisableLanguageExtensions="FALSE"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="3"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="winmm.lib"
|
||||||
|
OutputFile="$(OutDir)/unique_ptr_assign_test_d.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/unique_ptr_assign_test.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"
|
||||||
|
FixedBaseAddress="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Release"
|
||||||
|
IntermediateDirectory="Release/unique_ptr_assign_test"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories="../../../.."
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="FALSE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="0"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="winmm.lib"
|
||||||
|
OutputFile="$(OutDir)/unique_ptr_assign_test.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{7E3495A1-163E-57AC-5A6C-3A2754202BF4}">
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\test\unique_ptr_assign.cpp">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
135
proj/vc7ide/unique_ptr_ctordtor_test.vcproj
Normal file
135
proj/vc7ide/unique_ptr_ctordtor_test.vcproj
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="7.10"
|
||||||
|
Name="unique_ptr_ctordtor_test"
|
||||||
|
ProjectGUID="{C57C28A3-4FE0-6208-BF87-B2B61D3A7676}"
|
||||||
|
Keyword="Win32Proj">
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"/>
|
||||||
|
</Platforms>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Debug"
|
||||||
|
IntermediateDirectory="Debug/unique_ptr_ctordtor_test"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories="../../../.."
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
|
||||||
|
MinimalRebuild="TRUE"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
DisableLanguageExtensions="FALSE"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="3"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="winmm.lib"
|
||||||
|
OutputFile="$(OutDir)/unique_ptr_ctordtor_test_d.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/unique_ptr_ctordtor_test.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"
|
||||||
|
FixedBaseAddress="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Release"
|
||||||
|
IntermediateDirectory="Release/unique_ptr_ctordtor_test"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories="../../../.."
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="FALSE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="0"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="winmm.lib"
|
||||||
|
OutputFile="$(OutDir)/unique_ptr_ctordtor_test.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{7E3495A1-163E-57AC-5A6C-3A2754202BF6}">
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\test\unique_ptr_ctordtor.cpp">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
135
proj/vc7ide/unique_ptr_modifiers_test.vcproj
Normal file
135
proj/vc7ide/unique_ptr_modifiers_test.vcproj
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="7.10"
|
||||||
|
Name="unique_ptr_modifiers_test"
|
||||||
|
ProjectGUID="{C57C28A3-4FE0-6208-BF87-B2B61D3A7673}"
|
||||||
|
Keyword="Win32Proj">
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"/>
|
||||||
|
</Platforms>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Debug"
|
||||||
|
IntermediateDirectory="Debug/unique_ptr_modifiers_test"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories="../../../.."
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
|
||||||
|
MinimalRebuild="TRUE"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
DisableLanguageExtensions="FALSE"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="3"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="winmm.lib"
|
||||||
|
OutputFile="$(OutDir)/unique_ptr_modifiers_test_d.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/unique_ptr_modifiers_test.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"
|
||||||
|
FixedBaseAddress="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Release"
|
||||||
|
IntermediateDirectory="Release/unique_ptr_modifiers_test"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories="../../../.."
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="FALSE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="0"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="winmm.lib"
|
||||||
|
OutputFile="$(OutDir)/unique_ptr_modifiers_test.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{7E3495A1-163E-57AC-5A6C-3A2754202BF3}">
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\test\unique_ptr_modifiers.cpp">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
135
proj/vc7ide/unique_ptr_movector_test.vcproj
Normal file
135
proj/vc7ide/unique_ptr_movector_test.vcproj
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="7.10"
|
||||||
|
Name="unique_ptr_movector_test"
|
||||||
|
ProjectGUID="{C57C28A3-4FE0-6208-BF87-B2B61D3A7672}"
|
||||||
|
Keyword="Win32Proj">
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"/>
|
||||||
|
</Platforms>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Debug"
|
||||||
|
IntermediateDirectory="Debug/unique_ptr_movector_test"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories="../../../.."
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
|
||||||
|
MinimalRebuild="TRUE"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
DisableLanguageExtensions="FALSE"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="3"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="winmm.lib"
|
||||||
|
OutputFile="$(OutDir)/unique_ptr_movector_test_d.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/unique_ptr_movector_test.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"
|
||||||
|
FixedBaseAddress="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Release"
|
||||||
|
IntermediateDirectory="Release/unique_ptr_movector_test"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories="../../../.."
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="FALSE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="0"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="winmm.lib"
|
||||||
|
OutputFile="$(OutDir)/unique_ptr_movector_test.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{7E3495A1-163E-57AC-5A6C-3A2754202BF2}">
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\test\unique_ptr_movector.cpp">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
135
proj/vc7ide/unique_ptr_nullptr_test.vcproj
Normal file
135
proj/vc7ide/unique_ptr_nullptr_test.vcproj
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="7.10"
|
||||||
|
Name="unique_ptr_nullptr_test"
|
||||||
|
ProjectGUID="{C57C28A3-4FE0-6208-BF87-B2B61D3A7671}"
|
||||||
|
Keyword="Win32Proj">
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"/>
|
||||||
|
</Platforms>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Debug"
|
||||||
|
IntermediateDirectory="Debug/unique_ptr_nullptr_test"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories="../../../.."
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
|
||||||
|
MinimalRebuild="TRUE"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
DisableLanguageExtensions="FALSE"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="3"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="winmm.lib"
|
||||||
|
OutputFile="$(OutDir)/unique_ptr_nullptr_test_d.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/unique_ptr_nullptr_test.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"
|
||||||
|
FixedBaseAddress="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Release"
|
||||||
|
IntermediateDirectory="Release/unique_ptr_nullptr_test"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories="../../../.."
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="FALSE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="0"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="winmm.lib"
|
||||||
|
OutputFile="$(OutDir)/unique_ptr_nullptr_test.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{7E3495A1-163E-57AC-5A6C-3A2754202BF1}">
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\test\unique_ptr_nullptr.cpp">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
134
proj/vc7ide/unique_ptr_observers_test.vcproj
Normal file
134
proj/vc7ide/unique_ptr_observers_test.vcproj
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="7.10"
|
||||||
|
Name="unique_ptr_observers_test"
|
||||||
|
ProjectGUID="{C57C28A3-4FE0-6208-BF87-B2B61D3A7670}"
|
||||||
|
Keyword="Win32Proj">
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"/>
|
||||||
|
</Platforms>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Debug"
|
||||||
|
IntermediateDirectory="Debug/unique_ptr_observers_test"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories="../../../.."
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
|
||||||
|
MinimalRebuild="TRUE"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
DisableLanguageExtensions="FALSE"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="3"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="winmm.lib"
|
||||||
|
OutputFile="$(OutDir)/unique_ptr_observers_test_d.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/unique_ptr_observers_test.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"
|
||||||
|
FixedBaseAddress="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Release"
|
||||||
|
IntermediateDirectory="Release/unique_ptr_observers_test"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories="../../../.."
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="FALSE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="0"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="winmm.lib"
|
||||||
|
OutputFile="$(OutDir)/unique_ptr_observers_test.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{7E3495A1-163E-57AC-5A6C-3A2754202BF0}">
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\test\unique_ptr_observers.cpp">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
@@ -2,8 +2,8 @@
|
|||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="7.10"
|
Version="7.10"
|
||||||
Name="unique_ptr_test"
|
Name="unique_ptr_types_test"
|
||||||
ProjectGUID="{C57C28A3-4FE0-6208-BF87-A2B61D3A7671}"
|
ProjectGUID="{C57C28A3-4FE0-6208-BF87-B2B61D3A7675}"
|
||||||
Keyword="Win32Proj">
|
Keyword="Win32Proj">
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
OutputDirectory="../../Bin/Win32/Debug"
|
OutputDirectory="../../Bin/Win32/Debug"
|
||||||
IntermediateDirectory="Debug/unique_ptr_test"
|
IntermediateDirectory="Debug/unique_ptr_types_test"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="2">
|
CharacterSet="2">
|
||||||
<Tool
|
<Tool
|
||||||
@@ -36,11 +36,11 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="winmm.lib"
|
AdditionalDependencies="winmm.lib"
|
||||||
OutputFile="$(OutDir)/unique_ptr_test_d.exe"
|
OutputFile="$(OutDir)/unique_ptr_types_test_d.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="TRUE"
|
||||||
ProgramDatabaseFile="$(OutDir)/unique_ptr_test.pdb"
|
ProgramDatabaseFile="$(OutDir)/unique_ptr_types_test.pdb"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
FixedBaseAddress="1"/>
|
FixedBaseAddress="1"/>
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="../../Bin/Win32/Release"
|
OutputDirectory="../../Bin/Win32/Release"
|
||||||
IntermediateDirectory="Release/unique_ptr_test"
|
IntermediateDirectory="Release/unique_ptr_types_test"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="2">
|
CharacterSet="2">
|
||||||
<Tool
|
<Tool
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="winmm.lib"
|
AdditionalDependencies="winmm.lib"
|
||||||
OutputFile="$(OutDir)/unique_ptr_test.exe"
|
OutputFile="$(OutDir)/unique_ptr_types_test.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
AdditionalLibraryDirectories="../../../../stage/lib"
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="TRUE"
|
||||||
@@ -123,9 +123,9 @@
|
|||||||
<Filter
|
<Filter
|
||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
UniqueIdentifier="{7E3495A1-163E-57AC-5A6C-2A2754202BFA}">
|
UniqueIdentifier="{7E3495A1-163E-57AC-5A6C-3A2754202BF5}">
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\test\unique_ptr.cpp">
|
RelativePath="..\..\test\unique_ptr_types.cpp">
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
|
1907
test/unique_ptr.cpp
1907
test/unique_ptr.cpp
File diff suppressed because it is too large
Load Diff
444
test/unique_ptr_assign.cpp
Normal file
444
test/unique_ptr_assign.cpp
Normal file
@@ -0,0 +1,444 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Howard Hinnant 2009
|
||||||
|
// (C) Copyright Ion Gaztanaga 2014-2014.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/move for documentation.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
#include <boost/move/utility_core.hpp>
|
||||||
|
#include <boost/move/unique_ptr.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// The initial implementation of these tests
|
||||||
|
// was written by Howard Hinnant.
|
||||||
|
//
|
||||||
|
// These test were later refactored grouping
|
||||||
|
// and porting them to Boost.Move.
|
||||||
|
//
|
||||||
|
// Many thanks to Howard for releasing his C++03
|
||||||
|
// unique_ptr implementation with such detailed
|
||||||
|
// test cases.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "unique_ptr_test_utils_beg.hpp"
|
||||||
|
|
||||||
|
namespace bml = ::boost::movelib;
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_asgn_move_convert_defdel
|
||||||
|
////////////////////////////////
|
||||||
|
namespace unique_ptr_asgn_move_convert_defdel {
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<B> s(new B);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<A> s2(new A);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
s2 = boost::move(s);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(B::count == 1);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[]> s(new A[2]);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<const A[]> s2(new const A[2]);
|
||||||
|
BOOST_TEST(A::count == 4);
|
||||||
|
s2 = boost::move(s);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[2]> s(new A[2]);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<const A[2]> s2(new const A[2]);
|
||||||
|
BOOST_TEST(A::count == 4);
|
||||||
|
s2 = boost::move(s);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
bml::unique_ptr<A[2]> s(new A[2]);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<const A[]> s2(new const A[2]);
|
||||||
|
BOOST_TEST(A::count == 4);
|
||||||
|
s2 = boost::move(s);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_asgn_move_convert_defdel{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_asgn_move_convert_movdel
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_asgn_move_convert_movedel{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<B, move_constr_deleter<B> > s(new B);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<A, move_constr_deleter<A> > s2(new A);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
s2 = (boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(B::count == 1);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[], move_constr_deleter<A[]> > s(new A[2]);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<const A[], move_constr_deleter<const A[]> > s2(new const A[2]);
|
||||||
|
BOOST_TEST(A::count == 4);
|
||||||
|
s2 = (boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[2], move_constr_deleter<A[2]> > s(new A[3]);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<const A[2], move_constr_deleter<const A[2]> > s2(new const A[2]);
|
||||||
|
BOOST_TEST(A::count == 5);
|
||||||
|
s2 = (boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 3);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[2], move_constr_deleter<A[3]> > s(new A[2]);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<const A[], move_constr_deleter<const A[]> > s2(new const A[2]);
|
||||||
|
BOOST_TEST(A::count == 4);
|
||||||
|
s2 = (boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_asgn_move_convert_movedel{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_asgn_move_convert_copydelref
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_asgn_move_convert_copydelref{
|
||||||
|
|
||||||
|
// test converting move assignment with reference deleters
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
copy_constr_deleter<B> db(5);
|
||||||
|
bml::unique_ptr<B, copy_constr_deleter<B>&> s(new B, db);
|
||||||
|
A* p = s.get();
|
||||||
|
copy_constr_deleter<A> da(6);
|
||||||
|
bml::unique_ptr<A, copy_constr_deleter<A>&> s2(new A, da);
|
||||||
|
s2 = boost::move(s);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(B::count == 1);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
copy_constr_deleter<A[]> db(5);
|
||||||
|
bml::unique_ptr<A[], copy_constr_deleter<A[]>&> s(new A[2], db);
|
||||||
|
A* p = s.get();
|
||||||
|
copy_constr_deleter<const A[]> da(6);
|
||||||
|
bml::unique_ptr<const A[], copy_constr_deleter<const A[]>&> s2(new const A[2], da);
|
||||||
|
BOOST_TEST(A::count == 4);
|
||||||
|
s2 = boost::move(s);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
copy_constr_deleter<A[2]> db(5);
|
||||||
|
bml::unique_ptr<A[2], copy_constr_deleter<A[2]>&> s(new A[2], db);
|
||||||
|
A* p = s.get();
|
||||||
|
copy_constr_deleter<const A[2]> da(6);
|
||||||
|
bml::unique_ptr<const A[2], copy_constr_deleter<const A[2]>&> s2(new const A[2], da);
|
||||||
|
BOOST_TEST(A::count == 4);
|
||||||
|
s2 = boost::move(s);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
copy_constr_deleter<A[2]> db(5);
|
||||||
|
bml::unique_ptr<A[2], copy_constr_deleter<A[2]>&> s(new A[2], db);
|
||||||
|
A* p = s.get();
|
||||||
|
copy_constr_deleter<const A[]> da(6);
|
||||||
|
bml::unique_ptr<const A[], copy_constr_deleter<const A[]>&> s2(new const A[2], da);
|
||||||
|
BOOST_TEST(A::count == 4);
|
||||||
|
s2 = boost::move(s);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_asgn_move_convert_copydelref{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_asgn_move_defdel
|
||||||
|
////////////////////////////////
|
||||||
|
namespace unique_ptr_asgn_move_defdel {
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> s1(new A);
|
||||||
|
A* p = s1.get();
|
||||||
|
bml::unique_ptr<A> s2(new A);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
s2 = boost::move(s1);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s1.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[]> s1(new A[2]);
|
||||||
|
A* p = s1.get();
|
||||||
|
bml::unique_ptr<A[]> s2(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 4);
|
||||||
|
s2 = boost::move(s1);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s1.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[2]> s1(new A[2]);
|
||||||
|
A* p = s1.get();
|
||||||
|
bml::unique_ptr<A[2]> s2(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 4);
|
||||||
|
s2 = boost::move(s1);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s1.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //unique_ptr_asgn_move_defdel
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_asgn_move_movedel
|
||||||
|
////////////////////////////////
|
||||||
|
namespace unique_ptr_asgn_move_movedel {
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A, move_constr_deleter<A> > s1(new A);
|
||||||
|
A* p = s1.get();
|
||||||
|
bml::unique_ptr<A, move_constr_deleter<A> > s2(new A);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
s2 = boost::move(s1);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s1.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
BOOST_TEST(s1.get_deleter().state() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[], move_constr_deleter<A[]> > s1(new A[2]);
|
||||||
|
A* p = s1.get();
|
||||||
|
bml::unique_ptr<A[], move_constr_deleter<A[]> > s2(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 4);
|
||||||
|
s2 = boost::move(s1);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s1.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
BOOST_TEST(s1.get_deleter().state() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[2], move_constr_deleter<A[2]> > s1(new A[2]);
|
||||||
|
A* p = s1.get();
|
||||||
|
bml::unique_ptr<A[2], move_constr_deleter<A[2]> > s2(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 4);
|
||||||
|
s2 = boost::move(s1);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s1.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
BOOST_TEST(s1.get_deleter().state() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //unique_ptr_asgn_move_movedel
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_asgn_move_copydelref
|
||||||
|
////////////////////////////////
|
||||||
|
namespace unique_ptr_asgn_move_copydelref {
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
copy_constr_deleter<A> d1(5);
|
||||||
|
bml::unique_ptr<A, copy_constr_deleter<A>&> s1(new A, d1);
|
||||||
|
A* p = s1.get();
|
||||||
|
copy_constr_deleter<A> d2(6);
|
||||||
|
bml::unique_ptr<A, copy_constr_deleter<A>&> s2(new A, d2);
|
||||||
|
s2 = boost::move(s1);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s1.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(d1.state() == 5);
|
||||||
|
BOOST_TEST(d2.state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
copy_constr_deleter<A[]> d1(5);
|
||||||
|
bml::unique_ptr<A[], copy_constr_deleter<A[]>&> s1(new A[2], d1);
|
||||||
|
A* p = s1.get();
|
||||||
|
copy_constr_deleter<A[]> d2(6);
|
||||||
|
bml::unique_ptr<A[], copy_constr_deleter<A[]>&> s2(new A[2], d2);
|
||||||
|
BOOST_TEST(A::count == 4);
|
||||||
|
s2 = boost::move(s1);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s1.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
BOOST_TEST(d1.state() == 5);
|
||||||
|
BOOST_TEST(d2.state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
copy_constr_deleter<A[2]> d1(5);
|
||||||
|
bml::unique_ptr<A[2], copy_constr_deleter<A[2]>&> s1(new A[2], d1);
|
||||||
|
A* p = s1.get();
|
||||||
|
copy_constr_deleter<A[2]> d2(6);
|
||||||
|
bml::unique_ptr<A[2], copy_constr_deleter<A[2]>&> s2(new A[2], d2);
|
||||||
|
BOOST_TEST(A::count == 4);
|
||||||
|
s2 = boost::move(s1);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s1.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
BOOST_TEST(d1.state() == 5);
|
||||||
|
BOOST_TEST(d2.state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //unique_ptr_asgn_move_copydelref
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// main
|
||||||
|
////////////////////////////////
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
//Assignment
|
||||||
|
unique_ptr_asgn_move_convert_defdel::test();
|
||||||
|
unique_ptr_asgn_move_convert_movedel::test();
|
||||||
|
unique_ptr_asgn_move_convert_copydelref::test();
|
||||||
|
unique_ptr_asgn_move_defdel::test();
|
||||||
|
unique_ptr_asgn_move_movedel::test();
|
||||||
|
unique_ptr_asgn_move_copydelref::test();
|
||||||
|
|
||||||
|
//Test results
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "unique_ptr_test_utils_end.hpp"
|
708
test/unique_ptr_ctordtor.cpp
Normal file
708
test/unique_ptr_ctordtor.cpp
Normal file
@@ -0,0 +1,708 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Howard Hinnant 2009
|
||||||
|
// (C) Copyright Ion Gaztanaga 2014-2014.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/move for documentation.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
#include <boost/move/utility_core.hpp>
|
||||||
|
#include <boost/move/unique_ptr.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// The initial implementation of these tests
|
||||||
|
// was written by Howard Hinnant.
|
||||||
|
//
|
||||||
|
// These test were later refactored grouping
|
||||||
|
// and porting them to Boost.Move.
|
||||||
|
//
|
||||||
|
// Many thanks to Howard for releasing his C++03
|
||||||
|
// unique_ptr implementation with such detailed
|
||||||
|
// test cases.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "unique_ptr_test_utils_beg.hpp"
|
||||||
|
|
||||||
|
namespace bml = ::boost::movelib;
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_dtor_null
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_dtor_null{
|
||||||
|
|
||||||
|
// The deleter is not called if get() == 0
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
{
|
||||||
|
def_constr_deleter<int> d;
|
||||||
|
BOOST_TEST(d.state() == 5);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int, def_constr_deleter<int>&> p(0, d);
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
BOOST_TEST(&p.get_deleter() == &d);
|
||||||
|
}
|
||||||
|
BOOST_TEST(d.state() == 5);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
def_constr_deleter<int[]> d;
|
||||||
|
BOOST_TEST(d.state() == 5);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[], def_constr_deleter<int[]>&> p(0, d);
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
BOOST_TEST(&p.get_deleter() == &d);
|
||||||
|
}
|
||||||
|
BOOST_TEST(d.state() == 5);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
def_constr_deleter<int[2]> d;
|
||||||
|
BOOST_TEST(d.state() == 5);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[2], def_constr_deleter<int[2]>&> p(0, d);
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
BOOST_TEST(&p.get_deleter() == &d);
|
||||||
|
}
|
||||||
|
BOOST_TEST(d.state() == 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_dtor_null{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_default_delreq
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_default_delreq{
|
||||||
|
|
||||||
|
// default unique_ptr ctor should only require default deleter ctor
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int> p;
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int, def_constr_deleter<int> > p;
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
BOOST_TEST(p.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[]> p;
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[], def_constr_deleter<int[]> > p;
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
BOOST_TEST(p.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[]> p;
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[], def_constr_deleter<int[]> > p;
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
BOOST_TEST(p.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[2]> p;
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[2], def_constr_deleter<int[2]> > p;
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
BOOST_TEST(p.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_default_delreq{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_default_nocomplete
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_default_nocomplete{
|
||||||
|
|
||||||
|
// default unique_ptr ctor shouldn't require complete type
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
J<I> s;
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
}
|
||||||
|
check(0);
|
||||||
|
{
|
||||||
|
J<I, def_constr_deleter<I> > s;
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
check(0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
J<I[]> s;
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
}
|
||||||
|
check(0);
|
||||||
|
{
|
||||||
|
J<I[], def_constr_deleter<I[]> > s;
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
check(0);
|
||||||
|
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
J<I[2]> s;
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
}
|
||||||
|
check(0);
|
||||||
|
{
|
||||||
|
J<I[2], def_constr_deleter<I[2]> > s;
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
check(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_default_nocomplete{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_pointer_delreq
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_pointer_delreq{
|
||||||
|
|
||||||
|
// unique_ptr(pointer) ctor should only require default deleter ctor
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A;
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
bml::unique_ptr<A> s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
A* p = new A;
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
bml::unique_ptr<A, def_constr_deleter<A> > s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
bml::unique_ptr<A[]> s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
bml::unique_ptr<A[], def_constr_deleter<A[]> > s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
bml::unique_ptr<A[2]> s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
bml::unique_ptr<A[2], def_constr_deleter<A[2]> > s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_pointer_delreq{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_pointer_nocomplete
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_pointer_nocomplete{
|
||||||
|
|
||||||
|
// unique_ptr(pointer) ctor shouldn't require complete type
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
I* p = get();
|
||||||
|
check(1);
|
||||||
|
J<I> s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
}
|
||||||
|
check(0);
|
||||||
|
{
|
||||||
|
I* p = get();
|
||||||
|
check(1);
|
||||||
|
J<I, def_constr_deleter<I> > s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
check(0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
I* p = get_array(2);
|
||||||
|
check(2);
|
||||||
|
J<I[]> s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
}
|
||||||
|
check(0);
|
||||||
|
{
|
||||||
|
I* p = get_array(2);
|
||||||
|
check(2);
|
||||||
|
J<I[], def_constr_deleter<I[]> > s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
check(0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
I* p = get_array(2);
|
||||||
|
check(2);
|
||||||
|
J<I[]> s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
}
|
||||||
|
check(0);
|
||||||
|
{
|
||||||
|
I* p = get_array(2);
|
||||||
|
check(2);
|
||||||
|
J<I[2], def_constr_deleter<I[2]> > s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
check(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_pointer_nocomplete{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_pointer_convert
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_pointer_convert{
|
||||||
|
|
||||||
|
// unique_ptr(pointer) ctor should work with derived pointers
|
||||||
|
// or same types (cv aside) for unique_ptr<arrays>
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
B* p = new B;
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(B::count == 1);
|
||||||
|
bml::unique_ptr<A> s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
{
|
||||||
|
B* p = new B;
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(B::count == 1);
|
||||||
|
bml::unique_ptr<A, def_constr_deleter<A> > s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
bml::unique_ptr<const A[]> s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
const A* p = new const A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
bml::unique_ptr<const volatile A[], def_constr_deleter<const volatile A[]> > s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
bml::unique_ptr<const A[2]> s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
const A* p = new const A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
bml::unique_ptr<const volatile A[2], def_constr_deleter<const volatile A[2]> > s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_pointer_convert{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_pointer_deleter_movedel
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_pointer_deleter_movedel{
|
||||||
|
|
||||||
|
// test move ctor. Should only require a MoveConstructible deleter, or if
|
||||||
|
// deleter is a reference, not even that.
|
||||||
|
|
||||||
|
// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A;
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
move_constr_deleter<A> d;
|
||||||
|
bml::unique_ptr<A, move_constr_deleter<A> > s(p, ::boost::move(d));
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
bml::unique_ptr<A, move_constr_deleter<A> > s2(s.release(), move_constr_deleter<A>(6));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 6);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
move_constr_deleter<A[]> d;
|
||||||
|
bml::unique_ptr<A[], move_constr_deleter<A[]> > s(p, ::boost::move(d));
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
bml::unique_ptr<A[], move_constr_deleter<A[]> > s2(s.release(), move_constr_deleter<A[]>(6));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 6);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
move_constr_deleter<A[2]> d;
|
||||||
|
bml::unique_ptr<A[2], move_constr_deleter<A[2]> > s(p, ::boost::move(d));
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
bml::unique_ptr<A[2], move_constr_deleter<A[2]> > s2(s.release(), move_constr_deleter<A[2]>(6));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 6);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_pointer_deleter_movedel{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_pointer_deleter_copydel
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_pointer_deleter_copydel{
|
||||||
|
|
||||||
|
// unique_ptr(pointer, d) requires CopyConstructible deleter
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A;
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
copy_constr_deleter<A> d;
|
||||||
|
bml::unique_ptr<A, copy_constr_deleter<A> > s(p, d);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
d.set_state(6);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
copy_constr_deleter<A[]> d;
|
||||||
|
bml::unique_ptr<A[], copy_constr_deleter<A[]> > s(p, d);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
d.set_state(6);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
copy_constr_deleter<A[2]> d;
|
||||||
|
bml::unique_ptr<A[2], copy_constr_deleter<A[2]> > s(p, d);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
d.set_state(6);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_pointer_deleter_copydel{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_pointer_deleter_dfctrdelref
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_pointer_deleter_dfctrdelref{
|
||||||
|
|
||||||
|
// unique_ptr<T, D&>(pointer, d) does not requires CopyConstructible deleter
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A;
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
def_constr_deleter<A> d;
|
||||||
|
bml::unique_ptr<A, def_constr_deleter<A>&> s(p, d);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
d.set_state(6);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 6);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
def_constr_deleter<A[]> d;
|
||||||
|
bml::unique_ptr<A[], def_constr_deleter<A[]>&> s(p, d);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
d.set_state(6);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 6);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
def_constr_deleter<A[2]> d;
|
||||||
|
bml::unique_ptr<A[2], def_constr_deleter<A[2]>&> s(p, d);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
d.set_state(6);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 6);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_pointer_deleter_dfctrdelref{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_pointer_deleter_dfctrdelconstref
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_pointer_deleter_dfctrdelconstref{
|
||||||
|
|
||||||
|
// unique_ptr<T, const D&>(pointer, d) does not requires CopyConstructible deleter
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A;
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
def_constr_deleter<A> d;
|
||||||
|
bml::unique_ptr<A, const def_constr_deleter<A>&> s(p, d);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
def_constr_deleter<A[]> d;
|
||||||
|
bml::unique_ptr<A[], const def_constr_deleter<A[]>&> s(p, d);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
def_constr_deleter<A[2]> d;
|
||||||
|
bml::unique_ptr<A[2], const def_constr_deleter<A[2]>&> s(p, d);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_pointer_deleter_dfctrdelconstref{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_pointer_deleter_convert
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_pointer_deleter_convert{
|
||||||
|
|
||||||
|
// unique_ptr(pointer, deleter) should work with derived pointers
|
||||||
|
// or same (cv aside) types for array unique_ptrs
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
B* p = new B;
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(B::count == 1);
|
||||||
|
bml::unique_ptr<A, copy_constr_deleter<A> > s(p, copy_constr_deleter<A>());
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
bml::unique_ptr<const A[], copy_constr_deleter<const A[]> > s(p, copy_constr_deleter<const A[]>());
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
bml::unique_ptr<const A[2], copy_constr_deleter<const A[2]> > s(p, copy_constr_deleter<const A[2]>());
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 5);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_pointer_deleter_convert{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_pointer_deleter_void
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_pointer_deleter_void{
|
||||||
|
|
||||||
|
// unique_ptr(pointer, deleter) should work with function pointers
|
||||||
|
// unique_ptr<void> should work
|
||||||
|
|
||||||
|
bool my_free_called = false;
|
||||||
|
|
||||||
|
void my_free(void*)
|
||||||
|
{
|
||||||
|
my_free_called = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
bml::unique_ptr<void, void (*)(void*)> s(&i, my_free);
|
||||||
|
BOOST_TEST(s.get() == &i);
|
||||||
|
BOOST_TEST(s.get_deleter() == my_free);
|
||||||
|
BOOST_TEST(!my_free_called);
|
||||||
|
}
|
||||||
|
BOOST_TEST(my_free_called);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_pointer_deleter_void{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// main
|
||||||
|
////////////////////////////////
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
//Constructors/Destructor
|
||||||
|
unique_ptr_dtor_null::test();
|
||||||
|
unique_ptr_ctor_default_delreq::test();
|
||||||
|
unique_ptr_ctor_default_nocomplete::test();
|
||||||
|
unique_ptr_ctor_pointer_delreq::test();
|
||||||
|
unique_ptr_ctor_pointer_nocomplete::test();
|
||||||
|
unique_ptr_ctor_pointer_convert::test();
|
||||||
|
unique_ptr_ctor_pointer_deleter_movedel::test();
|
||||||
|
unique_ptr_ctor_pointer_deleter_copydel::test();
|
||||||
|
unique_ptr_ctor_pointer_deleter_dfctrdelref::test();
|
||||||
|
unique_ptr_ctor_pointer_deleter_dfctrdelconstref::test();
|
||||||
|
unique_ptr_ctor_pointer_deleter_convert::test();
|
||||||
|
unique_ptr_ctor_pointer_deleter_void::test();
|
||||||
|
|
||||||
|
//Test results
|
||||||
|
return boost::report_errors();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "unique_ptr_test_utils_end.hpp"
|
@@ -10,9 +10,7 @@
|
|||||||
// See http://www.boost.org/libs/move for documentation.
|
// See http://www.boost.org/libs/move for documentation.
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
#include <boost/move/detail/config_begin.hpp>
|
#include <boost/move/default_delete.hpp>
|
||||||
|
|
||||||
#include <boost/move/unique_ptr.hpp>
|
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
@@ -85,10 +83,73 @@ void test()
|
|||||||
d1(p);
|
d1(p);
|
||||||
BOOST_TEST(A::count == 0);
|
BOOST_TEST(A::count == 0);
|
||||||
}
|
}
|
||||||
|
//Bounded array element deleter
|
||||||
|
{
|
||||||
|
reset_counters();
|
||||||
|
bml::default_delete<A[2]> d2;
|
||||||
|
bml::default_delete<const A[2]> d1 = d2;
|
||||||
|
const A* p = new const A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
d1(p);
|
||||||
|
bml::default_delete<const A[]> d0 = d1;
|
||||||
|
d0(0);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace unique_ptr_dltr_dflt_convert_ctor{
|
} //namespace unique_ptr_dltr_dflt_convert_ctor{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_dltr_dflt_convert_assign
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_dltr_dflt_convert_assign{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single element deleter
|
||||||
|
{
|
||||||
|
reset_counters();
|
||||||
|
bml::default_delete<B> d2;
|
||||||
|
bml::default_delete<A> d1;
|
||||||
|
d1 = d2;
|
||||||
|
A* p = new B;
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(B::count == 1);
|
||||||
|
d1(p);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
}
|
||||||
|
//Array element deleter
|
||||||
|
{
|
||||||
|
reset_counters();
|
||||||
|
bml::default_delete<A[]> d2;
|
||||||
|
bml::default_delete<const A[]> d1;
|
||||||
|
d1 = d2;
|
||||||
|
const A* p = new const A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
d1(p);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
//Bounded array element deleter
|
||||||
|
{
|
||||||
|
reset_counters();
|
||||||
|
bml::default_delete<A[2]> d2;
|
||||||
|
bml::default_delete<const A[2]> d1;
|
||||||
|
d1 = d2;
|
||||||
|
const A* p = new const A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
d1(p);
|
||||||
|
bml::default_delete<const A[]> d0;
|
||||||
|
d0 = d1;
|
||||||
|
d0(0);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_dltr_dflt_convert_assign{
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
// unique_ptr_dltr_dflt_default
|
// unique_ptr_dltr_dflt_default
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@@ -115,6 +176,16 @@ void test()
|
|||||||
d(p);
|
d(p);
|
||||||
BOOST_TEST(A::count == 0);
|
BOOST_TEST(A::count == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
//Bounded Array element deleter
|
||||||
|
reset_counters();
|
||||||
|
bml::default_delete<A[10]> d;
|
||||||
|
A* p = new A[10];
|
||||||
|
BOOST_TEST(A::count == 10);
|
||||||
|
d(p);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace unique_ptr_dltr_dflt_default{
|
} //namespace unique_ptr_dltr_dflt_default{
|
||||||
@@ -125,10 +196,9 @@ void test()
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
unique_ptr_dltr_dflt_convert_ctor::test();
|
unique_ptr_dltr_dflt_convert_ctor::test();
|
||||||
|
unique_ptr_dltr_dflt_convert_assign::test();
|
||||||
unique_ptr_dltr_dflt_default::test();
|
unique_ptr_dltr_dflt_default::test();
|
||||||
|
|
||||||
//Test results
|
//Test results
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <boost/move/detail/config_end.hpp>
|
|
||||||
|
@@ -9,9 +9,9 @@
|
|||||||
// See http://www.boost.org/libs/move for documentation.
|
// See http://www.boost.org/libs/move for documentation.
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
#include <boost/move/detail/config_begin.hpp>
|
|
||||||
#include <boost/move/make_unique.hpp>
|
#include <boost/move/make_unique.hpp>
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
struct A
|
struct A
|
||||||
{
|
{
|
||||||
@@ -41,6 +41,27 @@ int B::count = 0;
|
|||||||
void reset_counters()
|
void reset_counters()
|
||||||
{ A::count = B::count = 0; }
|
{ A::count = B::count = 0; }
|
||||||
|
|
||||||
|
static const unsigned PatternSize = 8;
|
||||||
|
static const unsigned char ff_patternbuf[PatternSize] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||||
|
static const unsigned char ee_patternbuf[PatternSize] = { 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE };
|
||||||
|
|
||||||
|
struct default_init
|
||||||
|
{
|
||||||
|
static void* operator new(std::size_t sz)
|
||||||
|
{
|
||||||
|
void *const p = ::operator new(sz);
|
||||||
|
return std::memset(p, 0xFF, sz);
|
||||||
|
}
|
||||||
|
static void* operator new[](std::size_t sz)
|
||||||
|
{
|
||||||
|
void *const p = ::operator new[](sz);
|
||||||
|
return std::memset(p, 0xEE, sz);
|
||||||
|
}
|
||||||
|
unsigned char buf[PatternSize];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace bml = ::boost::movelib;
|
namespace bml = ::boost::movelib;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@@ -54,12 +75,18 @@ void test()
|
|||||||
//Single element deleter
|
//Single element deleter
|
||||||
reset_counters();
|
reset_counters();
|
||||||
{
|
{
|
||||||
|
bml::unique_ptr<default_init> p(bml::make_unique_definit<default_init>());
|
||||||
|
BOOST_TEST(0 == std::memcmp(p.get(), ff_patternbuf, sizeof(ff_patternbuf)));
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
bml::unique_ptr<A> p(bml::make_unique<A>());
|
bml::unique_ptr<A> p(bml::make_unique<A>());
|
||||||
BOOST_TEST(A::count == 1);
|
BOOST_TEST(A::count == 1);
|
||||||
BOOST_TEST(p->a == 999);
|
BOOST_TEST(p->a == 999);
|
||||||
BOOST_TEST(p->b == 1000);
|
BOOST_TEST(p->b == 1000);
|
||||||
BOOST_TEST(p->c == 1001);
|
BOOST_TEST(p->c == 1001);
|
||||||
}
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
{
|
{
|
||||||
bml::unique_ptr<A> p(bml::make_unique<A>(0));
|
bml::unique_ptr<A> p(bml::make_unique<A>(0));
|
||||||
BOOST_TEST(A::count == 1);
|
BOOST_TEST(A::count == 1);
|
||||||
@@ -96,7 +123,7 @@ namespace make_unique_array{
|
|||||||
|
|
||||||
void test()
|
void test()
|
||||||
{
|
{
|
||||||
//Single element deleter
|
//Array element
|
||||||
reset_counters();
|
reset_counters();
|
||||||
{
|
{
|
||||||
bml::unique_ptr<A[]> p(bml::make_unique<A[]>(10));
|
bml::unique_ptr<A[]> p(bml::make_unique<A[]>(10));
|
||||||
@@ -108,6 +135,13 @@ void test()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
BOOST_TEST(A::count == 0);
|
BOOST_TEST(A::count == 0);
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<default_init[]> p(bml::make_unique_definit<default_init[]>(10));
|
||||||
|
for(unsigned i = 0; i != 10; ++i){
|
||||||
|
BOOST_TEST(0 == std::memcmp(&p[i], ee_patternbuf, sizeof(ee_patternbuf)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace make_unique_array{
|
} //namespace make_unique_array{
|
||||||
@@ -135,30 +169,134 @@ void test()
|
|||||||
|
|
||||||
//Equal
|
//Equal
|
||||||
BOOST_TEST(rpl == rpl && rpl.get() == rpl.get());
|
BOOST_TEST(rpl == rpl && rpl.get() == rpl.get());
|
||||||
BOOST_TEST(!(rpl == rpg) && !(rpl.get() != rpg.get()));
|
BOOST_TEST(!(rpl == rpg) && !(rpl.get() == rpg.get()));
|
||||||
//Unequal
|
//Unequal
|
||||||
BOOST_TEST(rpl != rpg && rpl.get() != rpg.get());
|
BOOST_TEST(rpl != rpg && rpl.get() != rpg.get());
|
||||||
BOOST_TEST(!(rpl != rpl) && !(rpl.get() != rpl.get()));
|
BOOST_TEST(!(rpl != rpl) && !(rpl.get() != rpl.get()));
|
||||||
//Less
|
//Less
|
||||||
BOOST_TEST(rpl < rpg && rpl.get() < rpg.get());
|
BOOST_TEST(rpl < rpg && rpl.get() < rpg.get());
|
||||||
BOOST_TEST(!(rpl < rpg) && !(rpl.get() < rpg.get()));
|
BOOST_TEST(!(rpg < rpl) && !(rpg.get() < rpl.get()));
|
||||||
//Greater
|
//Greater
|
||||||
BOOST_TEST(rpg > rpl && rpg.get() > rpl.get());
|
BOOST_TEST(rpg > rpl && rpg.get() > rpl.get());
|
||||||
BOOST_TEST(!(rpg > rpg) && !(rpg.get() > rpl.get()));
|
BOOST_TEST(!(rpg > rpg) && !(rpg.get() > rpg.get()));
|
||||||
//Less or equal
|
//Less or equal
|
||||||
BOOST_TEST(rpl <= rpg && rpl.get() <= rpg.get());
|
BOOST_TEST(rpl <= rpg && rpl.get() <= rpg.get());
|
||||||
BOOST_TEST(rpl <= rpl && rpl.get() <= rpl.get());
|
BOOST_TEST(rpl <= rpl && rpl.get() <= rpl.get());
|
||||||
BOOST_TEST(!(rpg <= rpl) && !(rpg.get() < rpl.get()));
|
BOOST_TEST(!(rpg <= rpl) && !(rpg.get() <= rpl.get()));
|
||||||
//Greater or equal
|
//Greater or equal
|
||||||
BOOST_TEST(rpg >= rpl && rpg.get() >= rpl.get());
|
BOOST_TEST(rpg >= rpl && rpg.get() >= rpl.get());
|
||||||
BOOST_TEST(rpg >= rpg && rpg.get() >= rpg.get());
|
BOOST_TEST(rpg >= rpg && rpg.get() >= rpg.get());
|
||||||
BOOST_TEST(!(rpl >= rpg) && !(rpl.get() < rpg.get()));
|
BOOST_TEST(!(rpl >= rpg) && !(rpl.get() >= rpg.get()));
|
||||||
}
|
}
|
||||||
BOOST_TEST(A::count == 0);
|
BOOST_TEST(A::count == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace unique_compare{
|
} //namespace unique_compare{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_compare_zero
|
||||||
|
////////////////////////////////
|
||||||
|
namespace unique_compare_zero{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single element deleter
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> pa(bml::make_unique<A>());
|
||||||
|
bml::unique_ptr<A> pb;
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
|
||||||
|
//Equal
|
||||||
|
BOOST_TEST(!(pa == 0));
|
||||||
|
BOOST_TEST(!(0 == pa));
|
||||||
|
BOOST_TEST((pb == 0));
|
||||||
|
BOOST_TEST((0 == pb));
|
||||||
|
//Unequal
|
||||||
|
BOOST_TEST((pa != 0));
|
||||||
|
BOOST_TEST((0 != pa));
|
||||||
|
BOOST_TEST(!(pb != 0));
|
||||||
|
BOOST_TEST(!(0 != pb));
|
||||||
|
//Less
|
||||||
|
BOOST_TEST((pa < 0) == (pa.get() < 0));
|
||||||
|
BOOST_TEST((0 < pa) == (0 < pa.get()));
|
||||||
|
BOOST_TEST((pb < 0) == (pb.get() < 0));
|
||||||
|
BOOST_TEST((0 < pb) == (0 < pb.get()));
|
||||||
|
//Greater
|
||||||
|
BOOST_TEST((pa > 0) == (pa.get() > 0));
|
||||||
|
BOOST_TEST((0 > pa) == (0 > pa.get()));
|
||||||
|
BOOST_TEST((pb > 0) == (pb.get() > 0));
|
||||||
|
BOOST_TEST((0 > pb) == (0 > pb.get()));
|
||||||
|
//Less or equal
|
||||||
|
BOOST_TEST((pa <= 0) == (pa.get() <= 0));
|
||||||
|
BOOST_TEST((0 <= pa) == (0 <= pa.get()));
|
||||||
|
BOOST_TEST((pb <= 0) == (pb.get() <= 0));
|
||||||
|
BOOST_TEST((0 <= pb) == (0 <= pb.get()));
|
||||||
|
//Greater or equal
|
||||||
|
BOOST_TEST((pa >= 0) == (pa.get() >= 0));
|
||||||
|
BOOST_TEST((0 >= pa) == (0 >= pa.get()));
|
||||||
|
BOOST_TEST((pb >= 0) == (pb.get() >= 0));
|
||||||
|
BOOST_TEST((0 >= pb) == (0 >= pb.get()));
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_compare_zero{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_compare_nullptr
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_compare_nullptr{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
#if !defined(BOOST_NO_CXX11_NULLPTR)
|
||||||
|
//Single element deleter
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> pa(bml::make_unique<A>());
|
||||||
|
bml::unique_ptr<A> pb;
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
|
||||||
|
//Equal
|
||||||
|
BOOST_TEST(!(pa == nullptr));
|
||||||
|
BOOST_TEST(!(nullptr == pa));
|
||||||
|
BOOST_TEST((pb == nullptr));
|
||||||
|
BOOST_TEST((nullptr == pb));
|
||||||
|
//Unequal
|
||||||
|
BOOST_TEST((pa != nullptr));
|
||||||
|
BOOST_TEST((nullptr != pa));
|
||||||
|
BOOST_TEST(!(pb != nullptr));
|
||||||
|
BOOST_TEST(!(nullptr != pb));
|
||||||
|
//Less
|
||||||
|
BOOST_TEST((pa < nullptr) == (pa.get() < nullptr));
|
||||||
|
BOOST_TEST((nullptr < pa) == (nullptr < pa.get()));
|
||||||
|
BOOST_TEST((pb < nullptr) == (pb.get() < nullptr));
|
||||||
|
BOOST_TEST((nullptr < pb) == (nullptr < pb.get()));
|
||||||
|
//Greater
|
||||||
|
BOOST_TEST((pa > nullptr) == (pa.get() > nullptr));
|
||||||
|
BOOST_TEST((nullptr > pa) == (nullptr > pa.get()));
|
||||||
|
BOOST_TEST((pb > nullptr) == (pb.get() > nullptr));
|
||||||
|
BOOST_TEST((nullptr > pb) == (nullptr > pb.get()));
|
||||||
|
//Less or equal
|
||||||
|
BOOST_TEST((pa <= nullptr) == (pa.get() <= nullptr));
|
||||||
|
BOOST_TEST((nullptr <= pa) == (nullptr <= pa.get()));
|
||||||
|
BOOST_TEST((pb <= nullptr) == (pb.get() <= nullptr));
|
||||||
|
BOOST_TEST((nullptr <= pb) == (nullptr <= pb.get()));
|
||||||
|
//Greater or equal
|
||||||
|
BOOST_TEST((pa >= nullptr) == (pa.get() >= nullptr));
|
||||||
|
BOOST_TEST((nullptr >= pa) == (nullptr >= pa.get()));
|
||||||
|
BOOST_TEST((pb >= nullptr) == (pb.get() >= nullptr));
|
||||||
|
BOOST_TEST((nullptr >= pb) == (nullptr >= pb.get()));
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
#endif //#if !defined(BOOST_NO_CXX11_NULLPTR)
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_compare_nullptr{
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
// main
|
// main
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@@ -166,9 +304,10 @@ int main()
|
|||||||
{
|
{
|
||||||
make_unique_single::test();
|
make_unique_single::test();
|
||||||
make_unique_array::test();
|
make_unique_array::test();
|
||||||
|
unique_compare::test();
|
||||||
|
unique_compare_zero::test();
|
||||||
|
unique_compare_nullptr::test();
|
||||||
|
|
||||||
//Test results
|
//Test results
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <boost/move/detail/config_end.hpp>
|
|
||||||
|
377
test/unique_ptr_modifiers.cpp
Normal file
377
test/unique_ptr_modifiers.cpp
Normal file
@@ -0,0 +1,377 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Howard Hinnant 2009
|
||||||
|
// (C) Copyright Ion Gaztanaga 2014-2014.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/move for documentation.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
#include <boost/move/utility_core.hpp>
|
||||||
|
#include <boost/move/unique_ptr.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// The initial implementation of these tests
|
||||||
|
// was written by Howard Hinnant.
|
||||||
|
//
|
||||||
|
// These test were later refactored grouping
|
||||||
|
// and porting them to Boost.Move.
|
||||||
|
//
|
||||||
|
// Many thanks to Howard for releasing his C++03
|
||||||
|
// unique_ptr implementation with such detailed
|
||||||
|
// test cases.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "unique_ptr_test_utils_beg.hpp"
|
||||||
|
|
||||||
|
namespace bml = ::boost::movelib;
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_modifiers_release
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_modifiers_release{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int> p(new int(3));
|
||||||
|
int* i = p.get();
|
||||||
|
int* j = p.release();
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
BOOST_TEST(i == j);
|
||||||
|
}
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[]> p(new int[2]);
|
||||||
|
int* i = p.get();
|
||||||
|
int* j = p.release();
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
BOOST_TEST(i == j);
|
||||||
|
}
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[2]> p(new int[2]);
|
||||||
|
int* i = p.get();
|
||||||
|
int* j = p.release();
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
BOOST_TEST(i == j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_modifiers_release{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_modifiers_reset
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_modifiers_reset{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
{
|
||||||
|
reset_counters();
|
||||||
|
{ //reset()
|
||||||
|
bml::unique_ptr<A> p(new A);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset();
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{ //reset(p)
|
||||||
|
bml::unique_ptr<A> p(new A);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset(new A);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{ //reset(0)
|
||||||
|
bml::unique_ptr<A> p(new A);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset(0);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
reset_counters();
|
||||||
|
{ //reset()
|
||||||
|
bml::unique_ptr<A[]> p(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset();
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{ //reset(p)
|
||||||
|
bml::unique_ptr<A[]> p(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset(new A[3]);
|
||||||
|
BOOST_TEST(A::count == 3);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{ //reset(0)
|
||||||
|
bml::unique_ptr<A[]> p(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset(0);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{ //reset()
|
||||||
|
bml::unique_ptr<A[2]> p(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset();
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{ //reset(p)
|
||||||
|
bml::unique_ptr<A[2]> p(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset(new A[3]);
|
||||||
|
BOOST_TEST(A::count == 3);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{ //reset(0)
|
||||||
|
bml::unique_ptr<A[2]> p(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset(0);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_modifiers_reset{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_modifiers_reset_convert
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_modifiers_reset_convert{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> p(new A);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset(new B);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(B::count == 1);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> p(new B);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(B::count == 1);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset(new B);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(B::count == 1);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<const volatile A[2]> p(new const A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
const volatile A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset(new volatile A[3]);
|
||||||
|
BOOST_TEST(A::count == 3);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<const A[2]> p(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
const A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset(new const A[3]);
|
||||||
|
BOOST_TEST(A::count == 3);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<const volatile A[2]> p(new const A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
const volatile A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset(new volatile A[3]);
|
||||||
|
BOOST_TEST(A::count == 3);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<const A[2]> p(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
const A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset(new const A[3]);
|
||||||
|
BOOST_TEST(A::count == 3);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //unique_ptr_modifiers_reset_convert
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_modifiers
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_modifiers_swap{
|
||||||
|
|
||||||
|
// test swap
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p1 = new A(1);
|
||||||
|
move_constr_deleter<A> d1(1);
|
||||||
|
bml::unique_ptr<A, move_constr_deleter<A> > s1(p1, ::boost::move(d1));
|
||||||
|
A* p2 = new A(2);
|
||||||
|
move_constr_deleter<A> d2(2);
|
||||||
|
bml::unique_ptr<A, move_constr_deleter<A> > s2(p2, ::boost::move(d2));
|
||||||
|
BOOST_TEST(s1.get() == p1);
|
||||||
|
BOOST_TEST(*s1 == A(1));
|
||||||
|
BOOST_TEST(s1.get_deleter().state() == 1);
|
||||||
|
BOOST_TEST(s2.get() == p2);
|
||||||
|
BOOST_TEST(*s2 == A(2));
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 2);
|
||||||
|
swap(s1, s2);
|
||||||
|
BOOST_TEST(s1.get() == p2);
|
||||||
|
BOOST_TEST(*s1 == A(2));
|
||||||
|
BOOST_TEST(s1.get_deleter().state() == 2);
|
||||||
|
BOOST_TEST(s2.get() == p1);
|
||||||
|
BOOST_TEST(*s2 == A(1));
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 1);
|
||||||
|
}
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p1 = new A[2];
|
||||||
|
p1[0].set(1);
|
||||||
|
p1[1].set(2);
|
||||||
|
move_constr_deleter<A[]> d1(1);
|
||||||
|
bml::unique_ptr<A[], move_constr_deleter<A[]> > s1(p1, ::boost::move(d1));
|
||||||
|
A* p2 = new A[2];
|
||||||
|
p2[0].set(3);
|
||||||
|
p2[1].set(4);
|
||||||
|
move_constr_deleter<A[]> d2(2);
|
||||||
|
bml::unique_ptr<A[], move_constr_deleter<A[]> > s2(p2, ::boost::move(d2));
|
||||||
|
BOOST_TEST(s1.get() == p1);
|
||||||
|
BOOST_TEST(s1[0] == A(1));
|
||||||
|
BOOST_TEST(s1[1] == A(2));
|
||||||
|
BOOST_TEST(s1.get_deleter().state() == 1);
|
||||||
|
BOOST_TEST(s2.get() == p2);
|
||||||
|
BOOST_TEST(s2[0] == A(3));
|
||||||
|
BOOST_TEST(s2[1] == A(4));
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 2);
|
||||||
|
swap(s1, s2);
|
||||||
|
BOOST_TEST(s1.get() == p2);
|
||||||
|
BOOST_TEST(s1[0] == A(3));
|
||||||
|
BOOST_TEST(s1[1] == A(4));
|
||||||
|
BOOST_TEST(s1.get_deleter().state() == 2);
|
||||||
|
BOOST_TEST(s2.get() == p1);
|
||||||
|
BOOST_TEST(s2[0] == A(1));
|
||||||
|
BOOST_TEST(s2[1] == A(2));
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 1);
|
||||||
|
}
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
A* p1 = new A[2];
|
||||||
|
p1[0].set(1);
|
||||||
|
p1[1].set(2);
|
||||||
|
move_constr_deleter<A[2]> d1(1);
|
||||||
|
bml::unique_ptr<A[2], move_constr_deleter<A[2]> > s1(p1, ::boost::move(d1));
|
||||||
|
A* p2 = new A[2];
|
||||||
|
p2[0].set(3);
|
||||||
|
p2[1].set(4);
|
||||||
|
move_constr_deleter<A[2]> d2(2);
|
||||||
|
bml::unique_ptr<A[2], move_constr_deleter<A[2]> > s2(p2, ::boost::move(d2));
|
||||||
|
BOOST_TEST(s1.get() == p1);
|
||||||
|
BOOST_TEST(s1[0] == A(1));
|
||||||
|
BOOST_TEST(s1[1] == A(2));
|
||||||
|
BOOST_TEST(s1.get_deleter().state() == 1);
|
||||||
|
BOOST_TEST(s2.get() == p2);
|
||||||
|
BOOST_TEST(s2[0] == A(3));
|
||||||
|
BOOST_TEST(s2[1] == A(4));
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 2);
|
||||||
|
swap(s1, s2);
|
||||||
|
BOOST_TEST(s1.get() == p2);
|
||||||
|
BOOST_TEST(s1[0] == A(3));
|
||||||
|
BOOST_TEST(s1[1] == A(4));
|
||||||
|
BOOST_TEST(s1.get_deleter().state() == 2);
|
||||||
|
BOOST_TEST(s2.get() == p1);
|
||||||
|
BOOST_TEST(s2[0] == A(1));
|
||||||
|
BOOST_TEST(s2[1] == A(2));
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_modifiers_swap{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// main
|
||||||
|
////////////////////////////////
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
//Modifiers
|
||||||
|
unique_ptr_modifiers_release::test();
|
||||||
|
unique_ptr_modifiers_reset::test();
|
||||||
|
unique_ptr_modifiers_reset_convert::test();
|
||||||
|
unique_ptr_modifiers_swap::test();
|
||||||
|
|
||||||
|
//Test results
|
||||||
|
return boost::report_errors();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "unique_ptr_test_utils_end.hpp"
|
517
test/unique_ptr_movector.cpp
Normal file
517
test/unique_ptr_movector.cpp
Normal file
@@ -0,0 +1,517 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Howard Hinnant 2009
|
||||||
|
// (C) Copyright Ion Gaztanaga 2014-2014.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/move for documentation.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
#include <boost/move/utility_core.hpp>
|
||||||
|
#include <boost/move/unique_ptr.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// The initial implementation of these tests
|
||||||
|
// was written by Howard Hinnant.
|
||||||
|
//
|
||||||
|
// These test were later refactored grouping
|
||||||
|
// and porting them to Boost.Move.
|
||||||
|
//
|
||||||
|
// Many thanks to Howard for releasing his C++03
|
||||||
|
// unique_ptr implementation with such detailed
|
||||||
|
// test cases.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "unique_ptr_test_utils_beg.hpp"
|
||||||
|
|
||||||
|
namespace bml = ::boost::movelib;
|
||||||
|
namespace bmupmu = ::boost::move_upmu;
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_move_defdel
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_move_defdel{
|
||||||
|
|
||||||
|
// test converting move ctor. Should only require a MoveConstructible deleter, or if
|
||||||
|
// deleter is a reference, not even that.
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> s(new A);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<A> s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[]> s(new A[2]);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<A[]> s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[2]> s(new A[2]);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<A[2]> s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_move_defdel{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_move_movedel
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_move_movedel{
|
||||||
|
|
||||||
|
// test converting move ctor. Should only require a MoveConstructible deleter, or if
|
||||||
|
// deleter is a reference, not even that.
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A, move_constr_deleter<A> > s(new A);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<A, move_constr_deleter<A> > s2 = boost::move(s);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[], move_constr_deleter<A[]> > s(new A[2]);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<A[], move_constr_deleter<A[]> > s2 = boost::move(s);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[2]> s(new A[2]);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<A[2]> s2 = boost::move(s);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_move_movedel{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_move_dfctrdelref
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_move_dfctrdelref{
|
||||||
|
|
||||||
|
// test converting move ctor. Should only require a MoveConstructible deleter, or if
|
||||||
|
// deleter is a reference, not even that.
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
def_constr_deleter<A> d;
|
||||||
|
bml::unique_ptr<A, def_constr_deleter<A>&> s(new A, d);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<A, def_constr_deleter<A>&> s2 = boost::move(s);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
d.set_state(6);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == d.state());
|
||||||
|
BOOST_TEST(s.get_deleter().state() == d.state());
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
def_constr_deleter<A[]> d;
|
||||||
|
bml::unique_ptr<A[], def_constr_deleter<A[]>&> s(new A[2], d);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<A[], def_constr_deleter<A[]>&> s2 = boost::move(s);
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
d.set_state(6);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == d.state());
|
||||||
|
BOOST_TEST(s.get_deleter().state() == d.state());
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
def_constr_deleter<A[2]> d;
|
||||||
|
bml::unique_ptr<A[2], def_constr_deleter<A[2]>&> s(new A[2], d);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<A[2], def_constr_deleter<A[2]>&> s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
d.set_state(6);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == d.state());
|
||||||
|
BOOST_TEST(s.get_deleter().state() == d.state());
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_move_dfctrdelref{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_move_convert_defdel
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_move_convert_defdel{
|
||||||
|
|
||||||
|
// test converting move ctor. Should only require a MoveConstructible deleter, or if
|
||||||
|
// deleter is a reference, not even that.
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<B> s(new B);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<A> s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(B::count == 1);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[]> s(new A[2]);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<const volatile A[]> s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[2]> s(new A[2]);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<const volatile A[2]> s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[2]> s(new A[2]);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<const volatile A[]> s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_move_convert_defdel{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_move_convert_movedel
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_move_convert_movedel{
|
||||||
|
|
||||||
|
// test converting move ctor. Should only require a MoveConstructible deleter, or if
|
||||||
|
// deleter is a reference, not even that.
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_convertible<B, A>::value));
|
||||||
|
{
|
||||||
|
bml::unique_ptr<B, move_constr_deleter<B> > s(new B);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<A, move_constr_deleter<A> > s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(B::count == 1);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<const A[], move_constr_deleter<const A[]> > s(new const A[2]);
|
||||||
|
const A* p = s.get();
|
||||||
|
bml::unique_ptr<const volatile A[], move_constr_deleter<const volatile A[]> > s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<const A[2], move_constr_deleter<const A[2]> > s(new const A[2]);
|
||||||
|
const A* p = s.get();
|
||||||
|
bml::unique_ptr<const volatile A[2], move_constr_deleter<const volatile A[2]> > s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<const A[2], move_constr_deleter<const A[2]> > s(new const A[2]);
|
||||||
|
const A* p = s.get();
|
||||||
|
bml::unique_ptr<const volatile A[], move_constr_deleter<const volatile A[]> > s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == 5);
|
||||||
|
BOOST_TEST(s.get_deleter().state() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_move_convert_movedel{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_move_convert_dfctrdelref
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_move_convert_dfctrdelref{
|
||||||
|
|
||||||
|
// test converting move ctor. Should only require a MoveConstructible deleter, or if
|
||||||
|
// deleter is a reference, not even that.
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
def_constr_deleter<A> d;
|
||||||
|
bml::unique_ptr<B, def_constr_deleter<A>&> s(new B, d);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<A, def_constr_deleter<A>&> s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(B::count == 1);
|
||||||
|
d.set_state(6);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == d.state());
|
||||||
|
BOOST_TEST(s.get_deleter().state() == d.state());
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(B::count == 0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
def_constr_deleter<volatile A[]> d;
|
||||||
|
bml::unique_ptr<A[], def_constr_deleter<volatile A[]>&> s(new A[2], d);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<volatile A[], def_constr_deleter<volatile A[]>&> s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
d.set_state(6);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == d.state());
|
||||||
|
BOOST_TEST(s.get_deleter().state() == d.state());
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
def_constr_deleter<volatile A[2]> d;
|
||||||
|
bml::unique_ptr<A[2], def_constr_deleter<volatile A[2]>&> s(new A[2], d);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<volatile A[2], def_constr_deleter<volatile A[2]>&> s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
d.set_state(6);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == d.state());
|
||||||
|
BOOST_TEST(s.get_deleter().state() == d.state());
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
def_constr_deleter<volatile A[]> d;
|
||||||
|
bml::unique_ptr<A[2], def_constr_deleter<volatile A[]>&> s(new A[2], d);
|
||||||
|
A* p = s.get();
|
||||||
|
bml::unique_ptr<volatile A[], def_constr_deleter<volatile A[]>&> s2(boost::move(s));
|
||||||
|
BOOST_TEST(s2.get() == p);
|
||||||
|
BOOST_TEST(s.get() == 0);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
d.set_state(6);
|
||||||
|
BOOST_TEST(s2.get_deleter().state() == d.state());
|
||||||
|
BOOST_TEST(s.get_deleter().state() == d.state());
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_move_convert_dfctrdelref{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_ctor_move_sourcesink
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_ctor_move_sourcesink{
|
||||||
|
|
||||||
|
// test move ctor. Should only require a MoveConstructible deleter, or if
|
||||||
|
// deleter is a reference, not even that.
|
||||||
|
|
||||||
|
bml::unique_ptr<A> source1()
|
||||||
|
{ return bml::unique_ptr<A>(new A); }
|
||||||
|
|
||||||
|
bml::unique_ptr<A[]> source1_unbounded_array()
|
||||||
|
{ return bml::unique_ptr<A[]> (new A[2]); }
|
||||||
|
|
||||||
|
bml::unique_ptr<A[2]> source1_bounded_array()
|
||||||
|
{ return bml::unique_ptr<A[2]> (new A[2]); }
|
||||||
|
|
||||||
|
void sink1(bml::unique_ptr<A>)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void sink1_unbounded_array(bml::unique_ptr<A[]>)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void sink1_bounded_array(bml::unique_ptr<A[2]>)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bml::unique_ptr<A, move_constr_deleter<A> > source2()
|
||||||
|
{ return bml::unique_ptr<A, move_constr_deleter<A> > (new A); }
|
||||||
|
|
||||||
|
bml::unique_ptr<A[], move_constr_deleter<A[]> > source2_unbounded_array()
|
||||||
|
{ return bml::unique_ptr<A[], move_constr_deleter<A[]> >(new A[2]); }
|
||||||
|
|
||||||
|
bml::unique_ptr<A[2], move_constr_deleter<A[2]> > source2_bounded_array()
|
||||||
|
{ return bml::unique_ptr<A[2], move_constr_deleter<A[2]> >(new A[2]); }
|
||||||
|
|
||||||
|
void sink2(bml::unique_ptr<A, move_constr_deleter<A> >)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void sink2_unbounded_array(bml::unique_ptr<A[], move_constr_deleter<A[]> >)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void sink2_bounded_array(bml::unique_ptr<A[2], move_constr_deleter<A[2]> >)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bml::unique_ptr<A, def_constr_deleter<A>&> source3()
|
||||||
|
{
|
||||||
|
static def_constr_deleter<A> d;
|
||||||
|
return bml::unique_ptr<A, def_constr_deleter<A>&>(new A, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
bml::unique_ptr<A[], def_constr_deleter<A[]>&> source3_unbounded_array()
|
||||||
|
{
|
||||||
|
static def_constr_deleter<A[]> d;
|
||||||
|
return bml::unique_ptr<A[], def_constr_deleter<A[]>&>(new A[2], d);
|
||||||
|
}
|
||||||
|
|
||||||
|
bml::unique_ptr<A[2], def_constr_deleter<A[2]>&> source3_bounded_array()
|
||||||
|
{
|
||||||
|
static def_constr_deleter<A[2]> d;
|
||||||
|
return bml::unique_ptr<A[2], def_constr_deleter<A[2]>&>(new A[2], d);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sink3(bml::unique_ptr<A, def_constr_deleter<A>&> )
|
||||||
|
{}
|
||||||
|
|
||||||
|
void sink3_unbounded_array(bml::unique_ptr<A[], def_constr_deleter<A[]>&> )
|
||||||
|
{}
|
||||||
|
|
||||||
|
void sink3_bounded_array(bml::unique_ptr<A[2], def_constr_deleter<A[2]>&> )
|
||||||
|
{}
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
sink1(source1());
|
||||||
|
sink2(source2());
|
||||||
|
sink3(source3());
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
sink1_unbounded_array(source1_unbounded_array());
|
||||||
|
sink2_unbounded_array(source2_unbounded_array());
|
||||||
|
sink3_unbounded_array(source3_unbounded_array());
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
//Bbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
sink1_bounded_array(source1_bounded_array());
|
||||||
|
sink2_bounded_array(source2_bounded_array());
|
||||||
|
sink3_bounded_array(source3_bounded_array());
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_ctor_move_sourcesink{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// main
|
||||||
|
////////////////////////////////
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
//Move Constructor
|
||||||
|
unique_ptr_ctor_move_defdel::test();
|
||||||
|
unique_ptr_ctor_move_movedel::test();
|
||||||
|
unique_ptr_ctor_move_dfctrdelref::test();
|
||||||
|
unique_ptr_ctor_move_convert_defdel::test();
|
||||||
|
unique_ptr_ctor_move_convert_movedel::test();
|
||||||
|
unique_ptr_ctor_move_convert_dfctrdelref::test();
|
||||||
|
unique_ptr_ctor_move_sourcesink::test();
|
||||||
|
|
||||||
|
//Test results
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "unique_ptr_test_utils_end.hpp"
|
228
test/unique_ptr_nullptr.cpp
Normal file
228
test/unique_ptr_nullptr.cpp
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Howard Hinnant 2009
|
||||||
|
// (C) Copyright Ion Gaztanaga 2014-2014.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/move for documentation.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
#include <boost/move/utility_core.hpp>
|
||||||
|
#include <boost/move/unique_ptr.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// The initial implementation of these tests
|
||||||
|
// was written by Howard Hinnant.
|
||||||
|
//
|
||||||
|
// These test were later refactored grouping
|
||||||
|
// and porting them to Boost.Move.
|
||||||
|
//
|
||||||
|
// Many thanks to Howard for releasing his C++03
|
||||||
|
// unique_ptr implementation with such detailed
|
||||||
|
// test cases.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "unique_ptr_test_utils_beg.hpp"
|
||||||
|
|
||||||
|
namespace bml = ::boost::movelib;
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_zero
|
||||||
|
////////////////////////////////
|
||||||
|
namespace unique_ptr_zero {
|
||||||
|
|
||||||
|
// test initialization/assignment from zero
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> s2(0);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> s2(new A);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
s2 = 0;
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(s2.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[]> s2(0);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[]> s2(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
s2 = 0;
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(s2.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[2]> s2(0);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[2]> s2(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
s2 = 0;
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(s2.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_zero {
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_nullptr
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_nullptr{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
#if !defined(BOOST_NO_CXX11_NULLPTR)
|
||||||
|
//Single unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> p(new A);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset(nullptr);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> p(new A);
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p = nullptr;
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> pi(nullptr);
|
||||||
|
BOOST_TEST(pi.get() == nullptr);
|
||||||
|
BOOST_TEST(pi.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> pi(nullptr, bml::unique_ptr<A>::deleter_type());
|
||||||
|
BOOST_TEST(pi.get() == nullptr);
|
||||||
|
BOOST_TEST(pi.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[]> p(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset(nullptr);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[]> p(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p = nullptr;
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[]> pi(nullptr);
|
||||||
|
BOOST_TEST(pi.get() == nullptr);
|
||||||
|
BOOST_TEST(pi.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[]> pi(nullptr, bml::unique_ptr<A[]>::deleter_type());
|
||||||
|
BOOST_TEST(pi.get() == nullptr);
|
||||||
|
BOOST_TEST(pi.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[2]> p(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p.reset(nullptr);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[2]> p(new A[2]);
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
A* i = p.get();
|
||||||
|
(void)i;
|
||||||
|
p = nullptr;
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
BOOST_TEST(p.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[2]> pi(nullptr);
|
||||||
|
BOOST_TEST(pi.get() == nullptr);
|
||||||
|
BOOST_TEST(pi.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[2]> pi(nullptr, bml::unique_ptr<A[2]>::deleter_type());
|
||||||
|
BOOST_TEST(pi.get() == nullptr);
|
||||||
|
BOOST_TEST(pi.get() == 0);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_nullptr{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// main
|
||||||
|
////////////////////////////////
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
//nullptr
|
||||||
|
unique_ptr_zero::test();
|
||||||
|
unique_ptr_nullptr::test();
|
||||||
|
|
||||||
|
//Test results
|
||||||
|
return boost::report_errors();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "unique_ptr_test_utils_end.hpp"
|
287
test/unique_ptr_observers.cpp
Normal file
287
test/unique_ptr_observers.cpp
Normal file
@@ -0,0 +1,287 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Howard Hinnant 2009
|
||||||
|
// (C) Copyright Ion Gaztanaga 2014-2014.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/move for documentation.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
#include <boost/move/utility_core.hpp>
|
||||||
|
#include <boost/move/unique_ptr.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// The initial implementation of these tests
|
||||||
|
// was written by Howard Hinnant.
|
||||||
|
//
|
||||||
|
// These test were later refactored grouping
|
||||||
|
// and porting them to Boost.Move.
|
||||||
|
//
|
||||||
|
// Many thanks to Howard for releasing his C++03
|
||||||
|
// unique_ptr implementation with such detailed
|
||||||
|
// test cases.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "unique_ptr_test_utils_beg.hpp"
|
||||||
|
|
||||||
|
namespace bml = ::boost::movelib;
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_observers_dereference
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_observers_dereference{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int> p(new int(3));
|
||||||
|
BOOST_TEST(*p == 3);
|
||||||
|
}
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
int *pi = new int[2];
|
||||||
|
pi[0] = 3;
|
||||||
|
pi[1] = 4;
|
||||||
|
bml::unique_ptr<int[]> p(pi);
|
||||||
|
BOOST_TEST(p[0] == 3);
|
||||||
|
BOOST_TEST(p[1] == 4);
|
||||||
|
}
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
{
|
||||||
|
int *pi = new int[2];
|
||||||
|
pi[0] = 3;
|
||||||
|
pi[1] = 4;
|
||||||
|
bml::unique_ptr<int[2]> p(pi);
|
||||||
|
BOOST_TEST(p[0] == 3);
|
||||||
|
BOOST_TEST(p[1] == 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_observers_dereference{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_observers_dereference
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_observers_explicit_bool{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int> p(new int(3));
|
||||||
|
if (p)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
BOOST_TEST(false);
|
||||||
|
if (!p)
|
||||||
|
BOOST_TEST(false);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int> p;
|
||||||
|
if (!p)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
BOOST_TEST(false);
|
||||||
|
if (p)
|
||||||
|
BOOST_TEST(false);
|
||||||
|
}
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[]> p(new int[2]);
|
||||||
|
if (p)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
BOOST_TEST(false);
|
||||||
|
if (!p)
|
||||||
|
BOOST_TEST(false);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[]> p;
|
||||||
|
if (!p)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
BOOST_TEST(false);
|
||||||
|
if (p)
|
||||||
|
BOOST_TEST(false);
|
||||||
|
}
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[2]> p(new int[2]);
|
||||||
|
if (p)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
BOOST_TEST(false);
|
||||||
|
if (!p)
|
||||||
|
BOOST_TEST(false);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[2]> p;
|
||||||
|
if (!p)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
BOOST_TEST(false);
|
||||||
|
if (p)
|
||||||
|
BOOST_TEST(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_observers_explicit_bool{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_observers_get
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_observers_get{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
{
|
||||||
|
int* p = new int;
|
||||||
|
bml::unique_ptr<int> s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
}
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
int* p = new int[2];
|
||||||
|
bml::unique_ptr<int[]> s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
int* p = new int[2];
|
||||||
|
bml::unique_ptr<int[2]> s(p);
|
||||||
|
BOOST_TEST(s.get() == p);
|
||||||
|
}
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
{
|
||||||
|
int *pi = new int[2];
|
||||||
|
pi[0] = 3;
|
||||||
|
pi[1] = 4;
|
||||||
|
bml::unique_ptr<int[2]> p(pi);
|
||||||
|
BOOST_TEST(p[0] == 3);
|
||||||
|
BOOST_TEST(p[1] == 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_observers_get{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_observers_get_deleter
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_observers_get_deleter{
|
||||||
|
|
||||||
|
struct Deleter
|
||||||
|
{
|
||||||
|
void operator()(void*) {}
|
||||||
|
|
||||||
|
int test() {return 5;}
|
||||||
|
int test() const {return 6;}
|
||||||
|
};
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int, Deleter> p;
|
||||||
|
BOOST_TEST(p.get_deleter().test() == 5);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const bml::unique_ptr<int, Deleter> p;
|
||||||
|
BOOST_TEST(p.get_deleter().test() == 6);
|
||||||
|
}
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[], Deleter> p;
|
||||||
|
BOOST_TEST(p.get_deleter().test() == 5);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const bml::unique_ptr<int[], Deleter> p;
|
||||||
|
BOOST_TEST(p.get_deleter().test() == 6);
|
||||||
|
}
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<int[2], Deleter> p;
|
||||||
|
BOOST_TEST(p.get_deleter().test() == 5);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const bml::unique_ptr<int[2], Deleter> p;
|
||||||
|
BOOST_TEST(p.get_deleter().test() == 6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_observers_get_deleter{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_observers_op_arrow
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_observers_op_arrow{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> p(new A);
|
||||||
|
BOOST_TEST(p->state_ == 999);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_observers_op_arrow{
|
||||||
|
|
||||||
|
|
||||||
|
namespace unique_ptr_observers_op_index{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
A *pa = new A[2];
|
||||||
|
//pa[0] is left default constructed
|
||||||
|
pa[1].set(888);
|
||||||
|
bml::unique_ptr<A[]> p(pa);
|
||||||
|
BOOST_TEST(p[0].state_ == 999);
|
||||||
|
BOOST_TEST(p[1].state_ == 888);
|
||||||
|
}
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
{
|
||||||
|
A *pa = new A[2];
|
||||||
|
//pa[0] is left default constructed
|
||||||
|
pa[1].set(888);
|
||||||
|
bml::unique_ptr<A[2]> p(pa);
|
||||||
|
BOOST_TEST(p[0].state_ == 999);
|
||||||
|
BOOST_TEST(p[1].state_ == 888);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_observers_op_index{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// main
|
||||||
|
////////////////////////////////
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
//Observers
|
||||||
|
unique_ptr_observers_dereference::test();
|
||||||
|
unique_ptr_observers_explicit_bool::test();
|
||||||
|
unique_ptr_observers_get::test();
|
||||||
|
unique_ptr_observers_get_deleter::test();
|
||||||
|
unique_ptr_observers_op_arrow::test();
|
||||||
|
unique_ptr_observers_op_index::test();
|
||||||
|
|
||||||
|
//Test results
|
||||||
|
return boost::report_errors();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "unique_ptr_test_utils_end.hpp"
|
209
test/unique_ptr_test_utils_beg.hpp
Normal file
209
test/unique_ptr_test_utils_beg.hpp
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Howard Hinnant 2009
|
||||||
|
// (C) Copyright Ion Gaztanaga 2014-2014.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/move for documentation.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
#ifndef BOOST_MOVE_UNIQUE_PTR_TEST_UTILS_BEG_HPP
|
||||||
|
#define BOOST_MOVE_UNIQUE_PTR_TEST_UTILS_BEG_HPP
|
||||||
|
#include <boost/move/core.hpp>
|
||||||
|
#include <boost/move/detail/meta_utils.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// The initial implementation of these tests
|
||||||
|
// was written by Howard Hinnant.
|
||||||
|
//
|
||||||
|
// These test were later refactored grouping
|
||||||
|
// and porting them to Boost.Move.
|
||||||
|
//
|
||||||
|
// Many thanks to Howard for releasing his C++03
|
||||||
|
// unique_ptr implementation with such detailed
|
||||||
|
// test cases.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
//A deleter that can only default constructed
|
||||||
|
template <class T>
|
||||||
|
class def_constr_deleter
|
||||||
|
{
|
||||||
|
int state_;
|
||||||
|
def_constr_deleter(const def_constr_deleter&);
|
||||||
|
def_constr_deleter& operator=(const def_constr_deleter&);
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef typename ::boost::move_detail::remove_extent<T>::type element_type;
|
||||||
|
static const bool is_array = ::boost::move_detail::is_array<T>::value;
|
||||||
|
|
||||||
|
def_constr_deleter() : state_(5) {}
|
||||||
|
|
||||||
|
explicit def_constr_deleter(int s) : state_(s) {}
|
||||||
|
|
||||||
|
int state() const {return state_;}
|
||||||
|
|
||||||
|
void set_state(int s) {state_ = s;}
|
||||||
|
|
||||||
|
void operator()(element_type* p) const
|
||||||
|
{ is_array ? delete []p : delete p; }
|
||||||
|
|
||||||
|
void operator()(element_type* p)
|
||||||
|
{ ++state_; is_array ? delete []p : delete p; }
|
||||||
|
};
|
||||||
|
|
||||||
|
//A deleter that can be copy constructed
|
||||||
|
template <class T>
|
||||||
|
class copy_constr_deleter
|
||||||
|
{
|
||||||
|
int state_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef typename ::boost::move_detail::remove_extent<T>::type element_type;
|
||||||
|
static const bool is_array = ::boost::move_detail::is_array<T>::value;
|
||||||
|
|
||||||
|
copy_constr_deleter() : state_(5) {}
|
||||||
|
|
||||||
|
template<class U>
|
||||||
|
copy_constr_deleter(const copy_constr_deleter<U>&
|
||||||
|
, typename boost::move_upd::enable_def_del<U, T>::type* =0)
|
||||||
|
{ state_ = 5; }
|
||||||
|
|
||||||
|
explicit copy_constr_deleter(int s) : state_(s) {}
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
typename boost::move_upd::enable_def_del<U, T, copy_constr_deleter&>::type
|
||||||
|
operator=(const copy_constr_deleter<U> &d)
|
||||||
|
{
|
||||||
|
state_ = d.state();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
int state() const {return state_;}
|
||||||
|
|
||||||
|
void set_state(int s) {state_ = s;}
|
||||||
|
|
||||||
|
void operator()(element_type* p) const
|
||||||
|
{ is_array ? delete []p : delete p; }
|
||||||
|
|
||||||
|
void operator()(element_type* p)
|
||||||
|
{ ++state_; is_array ? delete []p : delete p; }
|
||||||
|
};
|
||||||
|
|
||||||
|
//A deleter that can be only move constructed
|
||||||
|
template <class T>
|
||||||
|
class move_constr_deleter
|
||||||
|
{
|
||||||
|
int state_;
|
||||||
|
|
||||||
|
BOOST_MOVABLE_BUT_NOT_COPYABLE(move_constr_deleter)
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef typename ::boost::move_detail::remove_extent<T>::type element_type;
|
||||||
|
static const bool is_array = ::boost::move_detail::is_array<T>::value;
|
||||||
|
|
||||||
|
move_constr_deleter() : state_(5) {}
|
||||||
|
|
||||||
|
move_constr_deleter(BOOST_RV_REF(move_constr_deleter) r)
|
||||||
|
: state_(r.state_)
|
||||||
|
{ r.state_ = 0; }
|
||||||
|
|
||||||
|
explicit move_constr_deleter(int s) : state_(s) {}
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
move_constr_deleter(BOOST_RV_REF(move_constr_deleter<U>) d
|
||||||
|
, typename boost::move_upd::enable_def_del<U, T>::type* =0)
|
||||||
|
: state_(d.state())
|
||||||
|
{ d.set_state(0); }
|
||||||
|
|
||||||
|
move_constr_deleter& operator=(BOOST_RV_REF(move_constr_deleter) r)
|
||||||
|
{
|
||||||
|
state_ = r.state_;
|
||||||
|
r.state_ = 0;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
typename boost::move_upd::enable_def_del<U, T, move_constr_deleter&>::type
|
||||||
|
operator=(BOOST_RV_REF(move_constr_deleter<U>) d)
|
||||||
|
{
|
||||||
|
state_ = d.state();
|
||||||
|
d.set_state(0);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
int state() const {return state_;}
|
||||||
|
|
||||||
|
void set_state(int s) {state_ = s;}
|
||||||
|
|
||||||
|
void operator()(element_type* p) const
|
||||||
|
{ is_array ? delete []p : delete p; }
|
||||||
|
|
||||||
|
void operator()(element_type* p)
|
||||||
|
{ ++state_; is_array ? delete []p : delete p; }
|
||||||
|
|
||||||
|
friend bool operator==(const move_constr_deleter& x, const move_constr_deleter& y)
|
||||||
|
{return x.state_ == y.state_;}
|
||||||
|
};
|
||||||
|
|
||||||
|
//A base class containing state with a static instance counter
|
||||||
|
struct A
|
||||||
|
{
|
||||||
|
int state_;
|
||||||
|
static int count;
|
||||||
|
|
||||||
|
A() : state_(999) {++count;}
|
||||||
|
explicit A(int i) : state_(i) {++count;}
|
||||||
|
A(const A& a) : state_(a.state_) {++count;}
|
||||||
|
A& operator=(const A& a) { state_ = a.state_; return *this; }
|
||||||
|
void set(int i) {state_ = i;}
|
||||||
|
virtual ~A() {--count;}
|
||||||
|
friend bool operator==(const A& x, const A& y) { return x.state_ == y.state_; }
|
||||||
|
};
|
||||||
|
|
||||||
|
int A::count = 0;
|
||||||
|
|
||||||
|
//A class derived from A with a static instance counter
|
||||||
|
struct B
|
||||||
|
: public A
|
||||||
|
{
|
||||||
|
static int count;
|
||||||
|
B() {++count;}
|
||||||
|
B(const B&) {++count;}
|
||||||
|
virtual ~B() {--count;}
|
||||||
|
};
|
||||||
|
|
||||||
|
int B::count = 0;
|
||||||
|
|
||||||
|
void reset_counters();
|
||||||
|
|
||||||
|
BOOST_STATIC_ASSERT((::boost::move_detail::is_convertible<B, A>::value));
|
||||||
|
|
||||||
|
//Incomplete Type function declarations
|
||||||
|
struct I;
|
||||||
|
void check(int i);
|
||||||
|
I* get();
|
||||||
|
I* get_array(int i);
|
||||||
|
|
||||||
|
#include <boost/move/unique_ptr.hpp>
|
||||||
|
|
||||||
|
template <class T, class D = ::boost::movelib::default_delete<T> >
|
||||||
|
struct J
|
||||||
|
{
|
||||||
|
typedef boost::movelib::unique_ptr<T, D> unique_ptr_type;
|
||||||
|
typedef typename unique_ptr_type::element_type element_type;
|
||||||
|
boost::movelib::unique_ptr<T, D> a_;
|
||||||
|
J() {}
|
||||||
|
explicit J(element_type*a) : a_(a) {}
|
||||||
|
~J();
|
||||||
|
|
||||||
|
element_type* get() const {return a_.get();}
|
||||||
|
D& get_deleter() {return a_.get_deleter();}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //BOOST_MOVE_UNIQUE_PTR_TEST_UTILS_BEG_HPP
|
46
test/unique_ptr_test_utils_end.hpp
Normal file
46
test/unique_ptr_test_utils_end.hpp
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Howard Hinnant 2009
|
||||||
|
// (C) Copyright Ion Gaztanaga 2014-2014.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/move for documentation.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
#ifndef BOOST_MOVE_UNIQUE_PTR_TEST_UTILS_END_HPP
|
||||||
|
#define BOOST_MOVE_UNIQUE_PTR_TEST_UTILS_END_HPP
|
||||||
|
|
||||||
|
#ifndef BOOST_MOVE_UNIQUE_PTR_TEST_UTILS_BEG_HPP
|
||||||
|
#error "unique_ptr_test_utils_beg.hpp MUST be included before this header"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//Define the incomplete I type and out of line functions
|
||||||
|
|
||||||
|
struct I
|
||||||
|
{
|
||||||
|
static int count;
|
||||||
|
I() {++count;}
|
||||||
|
I(const A&) {++count;}
|
||||||
|
~I() {--count;}
|
||||||
|
};
|
||||||
|
|
||||||
|
int I::count = 0;
|
||||||
|
|
||||||
|
I* get() {return new I;}
|
||||||
|
I* get_array(int i) {return new I[i];}
|
||||||
|
|
||||||
|
void check(int i)
|
||||||
|
{
|
||||||
|
BOOST_TEST(I::count == i);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class D>
|
||||||
|
J<T, D>::~J() {}
|
||||||
|
|
||||||
|
void reset_counters()
|
||||||
|
{ A::count = 0; B::count = 0; I::count = 0; }
|
||||||
|
|
||||||
|
#endif //BOOST_MOVE_UNIQUE_PTR_TEST_UTILS_END_HPP
|
165
test/unique_ptr_types.cpp
Normal file
165
test/unique_ptr_types.cpp
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Howard Hinnant 2009
|
||||||
|
// (C) Copyright Ion Gaztanaga 2014-2014.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/move for documentation.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
#include <boost/move/utility_core.hpp>
|
||||||
|
#include <boost/move/unique_ptr.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// The initial implementation of these tests
|
||||||
|
// was written by Howard Hinnant.
|
||||||
|
//
|
||||||
|
// These test were later refactored grouping
|
||||||
|
// and porting them to Boost.Move.
|
||||||
|
//
|
||||||
|
// Many thanks to Howard for releasing his C++03
|
||||||
|
// unique_ptr implementation with such detailed
|
||||||
|
// test cases.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "unique_ptr_test_utils_beg.hpp"
|
||||||
|
|
||||||
|
namespace bml = ::boost::movelib;
|
||||||
|
namespace bmupmu = ::boost::move_upmu;
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_pointer_type
|
||||||
|
////////////////////////////////
|
||||||
|
namespace unique_ptr_pointer_type {
|
||||||
|
|
||||||
|
struct Deleter
|
||||||
|
{
|
||||||
|
struct pointer {};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Test unique_ptr::pointer type
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int> P;
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_same<P::pointer, int*>::value));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int, Deleter> P;
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_same<P::pointer, Deleter::pointer>::value));
|
||||||
|
}
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[]> P;
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_same<P::pointer, int*>::value));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[], Deleter> P;
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_same<P::pointer, Deleter::pointer>::value));
|
||||||
|
}
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[5]> P;
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_same<P::pointer, int*>::value));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[5], Deleter> P;
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_same<P::pointer, Deleter::pointer>::value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_pointer_type {
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_deleter_type
|
||||||
|
////////////////////////////////
|
||||||
|
namespace unique_ptr_deleter_type {
|
||||||
|
|
||||||
|
struct Deleter
|
||||||
|
{};
|
||||||
|
|
||||||
|
// Test unique_ptr::deleter type
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int> P;
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_same<P::deleter_type, bml::default_delete<int> >::value));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int, Deleter> P;
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_same<P::deleter_type, Deleter >::value));
|
||||||
|
}
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[]> P;
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_same<P::deleter_type, bml::default_delete<int[]> >::value));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[], Deleter> P;
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_same<P::deleter_type, Deleter >::value));
|
||||||
|
}
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[2]> P;
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_same<P::deleter_type, bml::default_delete<int[2]> >::value));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[2], Deleter> P;
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_same<P::deleter_type, Deleter >::value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_deleter_type {
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_element_type
|
||||||
|
////////////////////////////////
|
||||||
|
namespace unique_ptr_element_type {
|
||||||
|
|
||||||
|
// Test unique_ptr::deleter type
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single unique_ptr
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<const int> P;
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_same<P::element_type, const int>::value));
|
||||||
|
}
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<const int[]> P;
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_same<P::element_type, const int>::value));
|
||||||
|
}
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<const int[2]> P;
|
||||||
|
BOOST_STATIC_ASSERT((bmupmu::is_same<P::element_type, const int>::value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_element_type {
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// main
|
||||||
|
////////////////////////////////
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
//General
|
||||||
|
unique_ptr_pointer_type::test();
|
||||||
|
unique_ptr_deleter_type::test();
|
||||||
|
unique_ptr_element_type::test();
|
||||||
|
|
||||||
|
//Test results
|
||||||
|
return boost::report_errors();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "unique_ptr_test_utils_end.hpp"
|
Reference in New Issue
Block a user