forked from boostorg/move
Added support for bounded arrays in unique_ptr. Splitted test in several subtests.
This commit is contained in:
@ -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
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
|
@ -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 {
|
||||||
|
@ -18,9 +18,7 @@
|
|||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_NULLPTR)
|
#include <cstddef> //For std::nullptr_t and std::size_t
|
||||||
#include <cstddef> //For std::nullptr_t
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//!\file
|
//!\file
|
||||||
//! Describes the smart pointer unique_ptr, a drop-in replacement for std::unique_ptr,
|
//! Describes the smart pointer unique_ptr, a drop-in replacement for std::unique_ptr,
|
||||||
@ -197,17 +195,37 @@ struct is_unique_ptr_convertible<false, FromPointer, ThisPointer>
|
|||||||
{};
|
{};
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
//// enable_def_del / enable_defdel_call
|
//// 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
|
||||||
|
{
|
||||||
|
static const bool value = is_convertible<U*, T*>::value;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class U, class T, std::size_t N>
|
||||||
|
struct def_del_compatible_cond<U[N], T[]>
|
||||||
|
{
|
||||||
|
static const bool value = def_del_compatible_cond<U[], T[]>::value;
|
||||||
|
};
|
||||||
|
|
||||||
template<class U, class T, class Type = nat>
|
template<class U, class T, class Type = nat>
|
||||||
struct enable_def_del
|
struct enable_def_del
|
||||||
: enable_if_c
|
: enable_if_c<def_del_compatible_cond<U, T>::value, Type>
|
||||||
< (is_array<T>::value == is_array<U>::value) && is_unique_ptr_convertible
|
|
||||||
<is_array<T>::value, typename remove_extent<U>::type*, typename remove_extent<T>::type*>::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 = nat>
|
template<class U, class T, class Type = nat>
|
||||||
struct enable_defdel_call
|
struct enable_defdel_call
|
||||||
: public enable_def_del<U, T, Type>
|
: public enable_def_del<U, T, Type>
|
||||||
@ -218,6 +236,11 @@ struct enable_defdel_call<U, T[], Type>
|
|||||||
: public enable_def_del<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>
|
||||||
|
{};
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
//// enable_up_moveconv_assign
|
//// enable_up_moveconv_assign
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
@ -234,17 +257,28 @@ struct enable_up_ptr
|
|||||||
template<class T, class D, class U, class E>
|
template<class T, class D, class U, class E>
|
||||||
struct unique_moveconvert_assignable
|
struct unique_moveconvert_assignable
|
||||||
{
|
{
|
||||||
static const bool value = !is_array<U>::value && is_unique_ptr_convertible
|
static const bool value = (extent<T>::value == extent<U>::value)&& is_unique_ptr_convertible
|
||||||
<false, typename pointer_type<U, E>::type, typename pointer_type<T, D>::type>::value;
|
<is_array<T>::value, typename pointer_type<U, E>::type, typename pointer_type<T, D>::type>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T, class D, class U, class E>
|
template<class T, class D, class U, class E, std::size_t N>
|
||||||
struct unique_moveconvert_assignable<T[], D, U, E>
|
struct unique_moveconvert_assignable<T[], D, U[N], E>
|
||||||
{
|
{
|
||||||
static const bool value = is_array<U>::value && is_unique_ptr_convertible
|
static const bool value = unique_moveconvert_assignable<T[], D, U[], E>::value;
|
||||||
<true, typename pointer_type<U, E>::type, typename pointer_type<T, D>::type>::value;
|
};
|
||||||
|
/*
|
||||||
|
template<class T, class D, class U, class E, std::size_t N>
|
||||||
|
struct unique_moveconvert_assignable<T[N], D, U[], E>
|
||||||
|
{
|
||||||
|
static const bool value = unique_moveconvert_assignable<nat[], D, U[], E>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class T, class D, class U, class E, std::size_t N, std::size_t M>
|
||||||
|
struct unique_moveconvert_assignable<T[N], D, U[M], E>
|
||||||
|
{
|
||||||
|
static const bool value = (M == N) && unique_moveconvert_assignable<T[], D, U[], E>::value;
|
||||||
|
};
|
||||||
|
*/
|
||||||
template<class T, class D, class U, class E, class Type = nat>
|
template<class T, class D, class U, class E, class Type = nat>
|
||||||
struct enable_up_moveconv_assign
|
struct enable_up_moveconv_assign
|
||||||
: enable_if_c<unique_moveconvert_assignable<T, D, U, E>::value, Type>
|
: enable_if_c<unique_moveconvert_assignable<T, D, U, E>::value, Type>
|
||||||
@ -394,6 +428,11 @@ struct default_delete
|
|||||||
element_type * const p = static_cast<element_type*>(ptr);
|
element_type * const p = static_cast<element_type*>(ptr);
|
||||||
bmd::is_array<T>::value ? delete [] p : delete p;
|
bmd::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(bmd::nullptr_type)) const BOOST_NOEXCEPT
|
||||||
|
{ BOOST_STATIC_ASSERT(sizeof(element_type) > 0); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -693,7 +732,7 @@ class unique_ptr
|
|||||||
operator*() const BOOST_NOEXCEPT
|
operator*() const BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
BOOST_STATIC_ASSERT((!bmd::is_array<T>::value));
|
BOOST_STATIC_ASSERT((!bmd::is_array<T>::value));
|
||||||
return *get();
|
return *m_data.m_p;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! <b>Requires</b>: i < the number of elements in the array to which the stored pointer points.
|
//! <b>Requires</b>: i < the number of elements in the array to which the stored pointer points.
|
||||||
@ -702,12 +741,11 @@ class unique_ptr
|
|||||||
//!
|
//!
|
||||||
//! <b>Remarks</b: If T is not an array type, the program is ill-formed.
|
//! <b>Remarks</b: If T is not an array type, the program is ill-formed.
|
||||||
BOOST_MOVE_DOC1ST(element_type&, typename bmd::add_lvalue_reference<element_type>::type)
|
BOOST_MOVE_DOC1ST(element_type&, typename bmd::add_lvalue_reference<element_type>::type)
|
||||||
operator[](size_t i) const BOOST_NOEXCEPT
|
operator[](std::size_t i) const BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
BOOST_STATIC_ASSERT((bmd::is_array<T>::value));
|
BOOST_ASSERT( bmd::extent<T>::value == 0 || i < bmd::extent<T>::value );
|
||||||
const pointer p = this->get();
|
BOOST_ASSERT(m_data.m_p);
|
||||||
BOOST_ASSERT(p);
|
return m_data.m_p[i];
|
||||||
return p[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! <b>Requires</b>: <tt>get() != nullptr</tt>.
|
//! <b>Requires</b>: <tt>get() != nullptr</tt>.
|
||||||
@ -720,9 +758,8 @@ class unique_ptr
|
|||||||
pointer operator->() const BOOST_NOEXCEPT
|
pointer operator->() const BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
BOOST_STATIC_ASSERT((!bmd::is_array<T>::value));
|
BOOST_STATIC_ASSERT((!bmd::is_array<T>::value));
|
||||||
const pointer p = this->get();
|
BOOST_ASSERT(m_data.m_p);
|
||||||
BOOST_ASSERT(p);
|
return m_data.m_p;
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! <b>Returns</b>: The stored pointer.
|
//! <b>Returns</b>: The stored pointer.
|
||||||
|
@ -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_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,14 +183,38 @@ 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
|
||||||
@ -182,6 +230,8 @@ 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
|
||||||
|
..\..\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
|
..\..\..\..\boost\move\detail\workaround.hpp = ..\..\..\..\boost\move\detail\workaround.hpp
|
||||||
|
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>
|
||||||
|
|
1983
test/unique_ptr.cpp
1983
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"
|
@ -83,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[2]> 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
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@ -113,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{
|
||||||
@ -123,6 +196,7 @@ 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
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
#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
|
||||||
{
|
{
|
||||||
@ -40,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;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@ -53,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);
|
||||||
@ -95,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));
|
||||||
@ -107,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{
|
||||||
@ -158,7 +193,6 @@ void test()
|
|||||||
|
|
||||||
} //namespace unique_compare{
|
} //namespace unique_compare{
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
// unique_compare_zero
|
// unique_compare_zero
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
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"
|
516
test/unique_ptr_movector.cpp
Normal file
516
test/unique_ptr_movector.cpp
Normal file
@ -0,0 +1,516 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (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_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((boost::move_detail::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_detail::enable_def_del<U, T>::type* =0)
|
||||||
|
{ state_ = 5; }
|
||||||
|
|
||||||
|
explicit copy_constr_deleter(int s) : state_(s) {}
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
typename boost::move_detail::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_detail::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_detail::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
|
164
test/unique_ptr_types.cpp
Normal file
164
test/unique_ptr_types.cpp
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (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_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((boost::move_detail::is_same<P::pointer, int*>::value));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int, Deleter> P;
|
||||||
|
BOOST_STATIC_ASSERT((boost::move_detail::is_same<P::pointer, Deleter::pointer>::value));
|
||||||
|
}
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[]> P;
|
||||||
|
BOOST_STATIC_ASSERT((boost::move_detail::is_same<P::pointer, int*>::value));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[], Deleter> P;
|
||||||
|
BOOST_STATIC_ASSERT((boost::move_detail::is_same<P::pointer, Deleter::pointer>::value));
|
||||||
|
}
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[5]> P;
|
||||||
|
BOOST_STATIC_ASSERT((boost::move_detail::is_same<P::pointer, int*>::value));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[5], Deleter> P;
|
||||||
|
BOOST_STATIC_ASSERT((boost::move_detail::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((boost::move_detail::is_same<P::deleter_type, bml::default_delete<int> >::value));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int, Deleter> P;
|
||||||
|
BOOST_STATIC_ASSERT((boost::move_detail::is_same<P::deleter_type, Deleter >::value));
|
||||||
|
}
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[]> P;
|
||||||
|
BOOST_STATIC_ASSERT((boost::move_detail::is_same<P::deleter_type, bml::default_delete<int[]> >::value));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[], Deleter> P;
|
||||||
|
BOOST_STATIC_ASSERT((boost::move_detail::is_same<P::deleter_type, Deleter >::value));
|
||||||
|
}
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[2]> P;
|
||||||
|
BOOST_STATIC_ASSERT((boost::move_detail::is_same<P::deleter_type, bml::default_delete<int[2]> >::value));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<int[2], Deleter> P;
|
||||||
|
BOOST_STATIC_ASSERT((boost::move_detail::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((boost::move_detail::is_same<P::element_type, const int>::value));
|
||||||
|
}
|
||||||
|
//Unbounded array unique_ptr
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<const int[]> P;
|
||||||
|
BOOST_STATIC_ASSERT((boost::move_detail::is_same<P::element_type, const int>::value));
|
||||||
|
}
|
||||||
|
//Bounded array unique_ptr
|
||||||
|
{
|
||||||
|
typedef bml::unique_ptr<const int[2]> P;
|
||||||
|
BOOST_STATIC_ASSERT((boost::move_detail::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