mirror of
https://github.com/boostorg/move.git
synced 2025-08-02 13:44:28 +02:00
Merge branch 'develop'
This commit is contained in:
@@ -21,7 +21,11 @@ doxygen autodoc
|
|||||||
<doxygen:param>EXTRACT_PRIVATE=NO
|
<doxygen:param>EXTRACT_PRIVATE=NO
|
||||||
<doxygen:param>ENABLE_PREPROCESSING=YES
|
<doxygen:param>ENABLE_PREPROCESSING=YES
|
||||||
<doxygen:param>MACRO_EXPANSION=YES
|
<doxygen:param>MACRO_EXPANSION=YES
|
||||||
<doxygen:param>"PREDEFINED=\"BOOST_MOVE_DOXYGEN_INVOKED\""
|
<doxygen:param>"PREDEFINED=\"BOOST_MOVE_DOXYGEN_INVOKED\" \\
|
||||||
|
\"BOOST_MOVE_SEEDOC(T)=see_documentation\" \\
|
||||||
|
\"BOOST_RV_REF(T)=T&&\" \\
|
||||||
|
\"BOOST_FWD_REF(T)=T&&\" \\
|
||||||
|
"
|
||||||
;
|
;
|
||||||
|
|
||||||
xml move : move.qbk ;
|
xml move : move.qbk ;
|
||||||
|
13
doc/move.qbk
13
doc/move.qbk
@@ -153,13 +153,13 @@ some good introduction and tutorials on rvalue references in these papers:
|
|||||||
* [@http://www.artima.com/cppsource/rvalue.html ['A Brief Introduction to Rvalue References]]
|
* [@http://www.artima.com/cppsource/rvalue.html ['A Brief Introduction to Rvalue References]]
|
||||||
* [@http://blogs.msdn.com/vcblog/archive/2009/02/03/rvalue-references-c-0x-features-in-vc10-part-2.aspx ['Rvalue References: C++0x Features in VC10, Part 2]]
|
* [@http://blogs.msdn.com/vcblog/archive/2009/02/03/rvalue-references-c-0x-features-in-vc10-part-2.aspx ['Rvalue References: C++0x Features in VC10, Part 2]]
|
||||||
|
|
||||||
When the source of the copy is known to be an `rvalue` (e.g.: a temporary object), one can avoid the
|
When the source of the copy is known to be a `rvalue` (e.g.: a temporary object), one can avoid the
|
||||||
potentially expensive `clone()` operation by pilfering source's pointer (no one will notice!). The move
|
potentially expensive `clone()` operation by pilfering source's pointer (no one will notice!). The move
|
||||||
constructor above does exactly that, leaving the rvalue in a default constructed state. The move assignment
|
constructor above does exactly that, leaving the rvalue in a default constructed state. The move assignment
|
||||||
operator simply does the same freeing old resources.
|
operator simply does the same freeing old resources.
|
||||||
|
|
||||||
Now when code tries to copy an rvalue `clone_ptr`, or if that code explicitly gives permission to
|
Now when code tries to copy a rvalue `clone_ptr`, or if that code explicitly gives permission to
|
||||||
consider the source of the copy an rvalue (using `boost::move`), the operation will execute much faster.
|
consider the source of the copy a rvalue (using `boost::move`), the operation will execute much faster.
|
||||||
|
|
||||||
[move_clone_ptr]
|
[move_clone_ptr]
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ increased. Movable but non-copyable types can be returned by value from factory
|
|||||||
data_file = create_file(/* ... */); // No copies!
|
data_file = create_file(/* ... */); // No copies!
|
||||||
|
|
||||||
In the above example, the underlying file handle is passed from object to object, as long
|
In the above example, the underlying file handle is passed from object to object, as long
|
||||||
as the source `file_descriptor` is an rvalue. At all times, there is still only one underlying file
|
as the source `file_descriptor` is a rvalue. At all times, there is still only one underlying file
|
||||||
handle, and only one `file_descriptor` owns it at a time.
|
handle, and only one `file_descriptor` owns it at a time.
|
||||||
|
|
||||||
To write a movable but not copyable type in portable syntax, you need to follow these simple steps:
|
To write a movable but not copyable type in portable syntax, you need to follow these simple steps:
|
||||||
@@ -427,7 +427,7 @@ both C++03 and C++11 compilers.
|
|||||||
[classref boost::move_iterator move_iterator] is an iterator adaptor with the
|
[classref boost::move_iterator move_iterator] is an iterator adaptor with the
|
||||||
same behavior as the underlying iterator
|
same behavior as the underlying iterator
|
||||||
except that its dereference operator implicitly converts the value returned by the
|
except that its dereference operator implicitly converts the value returned by the
|
||||||
underlying iterator's dereference operator to an rvalue reference: `boost::move(*underlying_iterator)`
|
underlying iterator's dereference operator to a rvalue reference: `boost::move(*underlying_iterator)`
|
||||||
It is a read-once iterator, but can have up to random access traversal characteristics.
|
It is a read-once iterator, but can have up to random access traversal characteristics.
|
||||||
|
|
||||||
`move_iterator` is very useful because some generic algorithms and container insertion functions
|
`move_iterator` is very useful because some generic algorithms and container insertion functions
|
||||||
@@ -455,7 +455,7 @@ provided with this library. With regular iterator classes,
|
|||||||
while (first != last) *result++ = *first++;
|
while (first != last) *result++ = *first++;
|
||||||
|
|
||||||
causes a range [first,last) to be copied into a range starting with result. The same code with
|
causes a range [first,last) to be copied into a range starting with result. The same code with
|
||||||
result being an move insert iterator will move insert corresponding elements into the container.
|
result being a move insert iterator will move insert corresponding elements into the container.
|
||||||
This device allows all of the copying algorithms in the library to work in the move insert mode
|
This device allows all of the copying algorithms in the library to work in the move insert mode
|
||||||
instead of the regular overwrite mode. This library offers 3 move insert iterators and their
|
instead of the regular overwrite mode. This library offers 3 move insert iterators and their
|
||||||
helper functions:
|
helper functions:
|
||||||
@@ -757,6 +757,7 @@ Many thanks to all boosters that have tested, reviewed and improved the library.
|
|||||||
|
|
||||||
[section:release_notes_boost_1_57_00 Boost 1.57 Release]
|
[section:release_notes_boost_1_57_00 Boost 1.57 Release]
|
||||||
|
|
||||||
|
* Added `unique_ptr` utility. Thanks to Howard Hinnant for his excellent unique_ptr emulation code and testsuite.
|
||||||
* Added `move_if_noexcept` utility. Thanks to Antony Polukhin for the implementation.
|
* Added `move_if_noexcept` utility. Thanks to Antony Polukhin for the implementation.
|
||||||
* Fixed bugs:
|
* Fixed bugs:
|
||||||
* [@https://svn.boost.org/trac/boost/ticket/9785 Trac #9785: ['"Compiler warning with intel icc in boost/move/core.hpp"]],
|
* [@https://svn.boost.org/trac/boost/ticket/9785 Trac #9785: ['"Compiler warning with intel icc in boost/move/core.hpp"]],
|
||||||
|
@@ -380,8 +380,8 @@
|
|||||||
#if !defined(BOOST_MOVE_MSVC_AUTO_MOVE_RETURN_BUG) || defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
#if !defined(BOOST_MOVE_MSVC_AUTO_MOVE_RETURN_BUG) || defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||||
|
|
||||||
//!This macro is used to achieve portable move return semantics.
|
//!This macro is used to achieve portable move return semantics.
|
||||||
//!The Standard allows implicit move returns when the object to be returned
|
//!The C++11 Standard allows implicit move returns when the object to be returned
|
||||||
//!is designated by an lvalue and:
|
//!is designated by a lvalue and:
|
||||||
//! - The criteria for elision of a copy operation are met OR
|
//! - The criteria for elision of a copy operation are met OR
|
||||||
//! - The criteria would be met save for the fact that the source object is a function parameter
|
//! - The criteria would be met save for the fact that the source object is a function parameter
|
||||||
//!
|
//!
|
||||||
|
@@ -20,4 +20,5 @@
|
|||||||
#endif
|
#endif
|
||||||
#pragma warning (push)
|
#pragma warning (push)
|
||||||
#pragma warning (disable : 4996) // "function": was declared deprecated
|
#pragma warning (disable : 4996) // "function": was declared deprecated
|
||||||
|
#pragma warning (disable : 4675) // "function": resolved overload was found by argument-dependent lookup
|
||||||
#endif
|
#endif
|
||||||
|
@@ -15,13 +15,37 @@
|
|||||||
#define BOOST_MOVE_DETAIL_META_UTILS_HPP
|
#define BOOST_MOVE_DETAIL_META_UTILS_HPP
|
||||||
|
|
||||||
#include <boost/move/detail/config_begin.hpp>
|
#include <boost/move/detail/config_begin.hpp>
|
||||||
|
#include <cstddef> //for std::size_t
|
||||||
|
|
||||||
//Small meta-typetraits to support move
|
//Small meta-typetraits to support move
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
|
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
|
//Forward declare boost::rv
|
||||||
|
template <class T> class rv;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace move_detail {
|
namespace move_detail {
|
||||||
|
|
||||||
//if_
|
//////////////////////////////////////
|
||||||
|
// empty
|
||||||
|
//////////////////////////////////////
|
||||||
|
struct empty{};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// nat
|
||||||
|
//////////////////////////////////////
|
||||||
|
struct nat{};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// natify
|
||||||
|
//////////////////////////////////////
|
||||||
|
template <class T> struct natify{};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// if_c
|
||||||
|
//////////////////////////////////////
|
||||||
template<bool C, typename T1, typename T2>
|
template<bool C, typename T1, typename T2>
|
||||||
struct if_c
|
struct if_c
|
||||||
{
|
{
|
||||||
@@ -34,6 +58,9 @@ struct if_c<false,T1,T2>
|
|||||||
typedef T2 type;
|
typedef T2 type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// if_
|
||||||
|
//////////////////////////////////////
|
||||||
template<typename T1, typename T2, typename T3>
|
template<typename T1, typename T2, typename T3>
|
||||||
struct if_
|
struct if_
|
||||||
{
|
{
|
||||||
@@ -41,22 +68,33 @@ struct if_
|
|||||||
};
|
};
|
||||||
|
|
||||||
//enable_if_
|
//enable_if_
|
||||||
template <bool B, class T = void>
|
template <bool B, class T = nat>
|
||||||
struct enable_if_c
|
struct enable_if_c
|
||||||
{
|
{
|
||||||
typedef T type;
|
typedef T type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// enable_if_c
|
||||||
|
//////////////////////////////////////
|
||||||
template <class T>
|
template <class T>
|
||||||
struct enable_if_c<false, T> {};
|
struct enable_if_c<false, T> {};
|
||||||
|
|
||||||
template <class Cond, class T = void>
|
//////////////////////////////////////
|
||||||
|
// enable_if
|
||||||
|
//////////////////////////////////////
|
||||||
|
template <class Cond, class T = nat>
|
||||||
struct enable_if : public enable_if_c<Cond::value, T> {};
|
struct enable_if : public enable_if_c<Cond::value, T> {};
|
||||||
|
|
||||||
template <class Cond, class T = void>
|
//////////////////////////////////////
|
||||||
|
// disable_if
|
||||||
|
//////////////////////////////////////
|
||||||
|
template <class Cond, class T = nat>
|
||||||
struct disable_if : public enable_if_c<!Cond::value, T> {};
|
struct disable_if : public enable_if_c<!Cond::value, T> {};
|
||||||
|
|
||||||
//integral_constant
|
//////////////////////////////////////
|
||||||
|
// integral_constant
|
||||||
|
//////////////////////////////////////
|
||||||
template<class T, T v>
|
template<class T, T v>
|
||||||
struct integral_constant
|
struct integral_constant
|
||||||
{
|
{
|
||||||
@@ -65,62 +103,37 @@ struct integral_constant
|
|||||||
typedef integral_constant<T, v> type;
|
typedef integral_constant<T, v> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
//identity
|
typedef integral_constant<bool, true > true_type;
|
||||||
|
typedef integral_constant<bool, false > false_type;
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// identity
|
||||||
|
//////////////////////////////////////
|
||||||
template <class T>
|
template <class T>
|
||||||
struct identity
|
struct identity
|
||||||
{
|
{
|
||||||
typedef T type;
|
typedef T type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
//////////////////////////////////////
|
||||||
|
// and_
|
||||||
//use intrinsic since in MSVC
|
//////////////////////////////////////
|
||||||
//overaligned types can't go through ellipsis
|
|
||||||
template <class T, class U>
|
|
||||||
struct is_convertible
|
|
||||||
{
|
|
||||||
static const bool value = __is_convertible_to(T, U);
|
|
||||||
};
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
template <class T, class U>
|
|
||||||
class is_convertible
|
|
||||||
{
|
|
||||||
typedef char true_t;
|
|
||||||
class false_t { char dummy[2]; };
|
|
||||||
static false_t dispatch(...);
|
|
||||||
static true_t dispatch(U);
|
|
||||||
static T &trigger();
|
|
||||||
public:
|
|
||||||
static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//and_ not_
|
|
||||||
template <typename Condition1, typename Condition2, typename Condition3 = integral_constant<bool, true> >
|
template <typename Condition1, typename Condition2, typename Condition3 = integral_constant<bool, true> >
|
||||||
struct and_
|
struct and_
|
||||||
: public integral_constant<bool, Condition1::value && Condition2::value && Condition3::value>
|
: public integral_constant<bool, Condition1::value && Condition2::value && Condition3::value>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// not_
|
||||||
|
//////////////////////////////////////
|
||||||
template <typename Boolean>
|
template <typename Boolean>
|
||||||
struct not_
|
struct not_
|
||||||
: public integral_constant<bool, !Boolean::value>
|
: public integral_constant<bool, !Boolean::value>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
//is_lvalue_reference
|
//////////////////////////////////////
|
||||||
template<class T>
|
// remove_reference
|
||||||
struct is_lvalue_reference
|
//////////////////////////////////////
|
||||||
: public integral_constant<bool, false>
|
|
||||||
{};
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
struct is_lvalue_reference<T&>
|
|
||||||
: public integral_constant<bool, true>
|
|
||||||
{};
|
|
||||||
|
|
||||||
//remove_reference
|
|
||||||
template<class T>
|
template<class T>
|
||||||
struct remove_reference
|
struct remove_reference
|
||||||
{
|
{
|
||||||
@@ -133,7 +146,6 @@ struct remove_reference<T&>
|
|||||||
typedef T type;
|
typedef T type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@@ -142,9 +154,73 @@ struct remove_reference<T&&>
|
|||||||
typedef T type;
|
typedef T type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct remove_reference< rv<T> >
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct remove_reference< rv<T> &>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct remove_reference< const rv<T> &>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//add_const
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// remove_const
|
||||||
|
//////////////////////////////////////
|
||||||
|
template< class T >
|
||||||
|
struct remove_const
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< class T >
|
||||||
|
struct remove_const<const T>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// remove_volatile
|
||||||
|
//////////////////////////////////////
|
||||||
|
template< class T >
|
||||||
|
struct remove_volatile
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< class T >
|
||||||
|
struct remove_volatile<volatile T>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// remove_cv
|
||||||
|
//////////////////////////////////////
|
||||||
|
template< class T >
|
||||||
|
struct remove_cv
|
||||||
|
{
|
||||||
|
typedef typename remove_volatile
|
||||||
|
<typename remove_const<T>::type>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// add_const
|
||||||
|
//////////////////////////////////////
|
||||||
template<class T>
|
template<class T>
|
||||||
struct add_const
|
struct add_const
|
||||||
{
|
{
|
||||||
@@ -154,7 +230,7 @@ struct add_const
|
|||||||
template<class T>
|
template<class T>
|
||||||
struct add_const<T&>
|
struct add_const<T&>
|
||||||
{
|
{
|
||||||
typedef T& type;
|
typedef const T& type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
@@ -167,7 +243,171 @@ struct add_const<T&&>
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// remove_extent
|
||||||
|
//////////////////////////////////////
|
||||||
|
template<class T>
|
||||||
|
struct remove_extent
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct remove_extent<T[]>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, std::size_t N>
|
||||||
|
struct remove_extent<T[N]>
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// element_pointer
|
||||||
|
//////////////////////////////////////
|
||||||
|
template<class T>
|
||||||
|
struct element_pointer
|
||||||
|
{
|
||||||
|
typedef typename remove_extent<T>::type element_type;
|
||||||
|
typedef element_type* type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// add_lvalue_reference
|
||||||
|
//////////////////////////////////////
|
||||||
|
template<class T>
|
||||||
|
struct add_lvalue_reference
|
||||||
|
{
|
||||||
|
typedef T& type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct add_lvalue_reference<T&>
|
||||||
|
{
|
||||||
|
typedef T& type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct add_lvalue_reference<void>
|
||||||
|
{
|
||||||
|
typedef void type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct add_lvalue_reference<const void>
|
||||||
|
{
|
||||||
|
typedef const void type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct add_lvalue_reference<volatile void>
|
||||||
|
{
|
||||||
|
typedef volatile void type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct add_lvalue_reference<const volatile void>
|
||||||
|
{
|
||||||
|
typedef const volatile void type;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// is_same
|
||||||
|
//////////////////////////////////////
|
||||||
|
template<class T, class U>
|
||||||
|
struct is_same
|
||||||
|
{
|
||||||
|
static const bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct is_same<T, T>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// is_pointer
|
||||||
|
//////////////////////////////////////
|
||||||
|
template< class T >
|
||||||
|
struct is_pointer
|
||||||
|
{
|
||||||
|
static const bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< class T >
|
||||||
|
struct is_pointer<T*>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// is_reference
|
||||||
|
//////////////////////////////////////
|
||||||
|
template< class T >
|
||||||
|
struct is_reference
|
||||||
|
{
|
||||||
|
static const bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< class T >
|
||||||
|
struct is_reference<T&>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
|
|
||||||
|
template< class T >
|
||||||
|
struct is_reference<T&&>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// is_lvalue_reference
|
||||||
|
//////////////////////////////////////
|
||||||
|
template<class T>
|
||||||
|
struct is_lvalue_reference
|
||||||
|
{
|
||||||
|
static const bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct is_lvalue_reference<T&>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// is_array
|
||||||
|
//////////////////////////////////////
|
||||||
|
template<class T>
|
||||||
|
struct is_array
|
||||||
|
{
|
||||||
|
static const bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct is_array<T[]>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, std::size_t N>
|
||||||
|
struct is_array<T[N]>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// is_class_or_union
|
||||||
|
//////////////////////////////////////
|
||||||
template<class T>
|
template<class T>
|
||||||
struct is_class_or_union
|
struct is_class_or_union
|
||||||
{
|
{
|
||||||
@@ -179,10 +419,11 @@ struct is_class_or_union
|
|||||||
static const bool value = sizeof(is_class_or_union_tester<T>(0)) == sizeof(char);
|
static const bool value = sizeof(is_class_or_union_tester<T>(0)) == sizeof(char);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct empty{};
|
//////////////////////////////////////
|
||||||
|
// addressof
|
||||||
//addressof
|
//////////////////////////////////////
|
||||||
template<class T> struct addr_impl_ref
|
template<class T>
|
||||||
|
struct addr_impl_ref
|
||||||
{
|
{
|
||||||
T & v_;
|
T & v_;
|
||||||
inline addr_impl_ref( T & v ): v_( v ) {}
|
inline addr_impl_ref( T & v ): v_( v ) {}
|
||||||
@@ -192,7 +433,8 @@ template<class T> struct addr_impl_ref
|
|||||||
addr_impl_ref & operator=(const addr_impl_ref &);
|
addr_impl_ref & operator=(const addr_impl_ref &);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T> struct addressof_impl
|
template<class T>
|
||||||
|
struct addressof_impl
|
||||||
{
|
{
|
||||||
static inline T * f( T & v, long )
|
static inline T * f( T & v, long )
|
||||||
{
|
{
|
||||||
@@ -211,6 +453,198 @@ inline T * addressof( T & v )
|
|||||||
( ::boost::move_detail::addr_impl_ref<T>( v ), 0 );
|
( ::boost::move_detail::addr_impl_ref<T>( v ), 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// has_pointer_type
|
||||||
|
//////////////////////////////////////
|
||||||
|
template <class T>
|
||||||
|
struct has_pointer_type
|
||||||
|
{
|
||||||
|
struct two { char c[2]; };
|
||||||
|
template <class U> static two test(...);
|
||||||
|
template <class U> static char test(typename U::pointer* = 0);
|
||||||
|
static const bool value = sizeof(test<T>(0)) == 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// pointer_type
|
||||||
|
//////////////////////////////////////
|
||||||
|
template <class T, class D, bool = has_pointer_type<D>::value>
|
||||||
|
struct pointer_type_imp
|
||||||
|
{
|
||||||
|
typedef typename D::pointer type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T, class D>
|
||||||
|
struct pointer_type_imp<T, D, false>
|
||||||
|
{
|
||||||
|
typedef typename remove_extent<T>::type* type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T, class D>
|
||||||
|
struct pointer_type
|
||||||
|
{
|
||||||
|
typedef typename pointer_type_imp<T, typename remove_reference<D>::type>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// is_convertible
|
||||||
|
//////////////////////////////////////
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||||
|
|
||||||
|
//use intrinsic since in MSVC
|
||||||
|
//overaligned types can't go through ellipsis
|
||||||
|
template <class T, class U>
|
||||||
|
struct is_convertible
|
||||||
|
{
|
||||||
|
static const bool value = __is_convertible_to(T, U);
|
||||||
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
class is_convertible
|
||||||
|
{
|
||||||
|
typedef typename add_lvalue_reference<T>::type t_reference;
|
||||||
|
typedef char true_t;
|
||||||
|
class false_t { char dummy[2]; };
|
||||||
|
static false_t dispatch(...);
|
||||||
|
static true_t dispatch(U);
|
||||||
|
static t_reference trigger();
|
||||||
|
public:
|
||||||
|
static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// is_unary_or_binary_function
|
||||||
|
//////////////////////////////////////
|
||||||
|
#if defined(BOOST_MSVC) || defined(__BORLANDC_)
|
||||||
|
#define BOOST_MOVE_TT_DECL __cdecl
|
||||||
|
#else
|
||||||
|
#define BOOST_MOVE_TT_DECL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_EXTENSIONS) && !defined(__BORLAND__) && !defined(_WIN64) && !defined(_M_ARM) && !defined(UNDER_CE)
|
||||||
|
#define BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct is_unary_or_binary_function_impl
|
||||||
|
{ static const bool value = false; };
|
||||||
|
|
||||||
|
// avoid duplicate definitions of is_unary_or_binary_function_impl
|
||||||
|
#ifndef BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
|
||||||
|
template <typename R>
|
||||||
|
struct is_unary_or_binary_function_impl<R (*)()>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
template <typename R>
|
||||||
|
struct is_unary_or_binary_function_impl<R (*)(...)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#else // BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
|
||||||
|
template <typename R>
|
||||||
|
struct is_unary_or_binary_function_impl<R (__stdcall*)()>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#ifndef _MANAGED
|
||||||
|
|
||||||
|
template <typename R>
|
||||||
|
struct is_unary_or_binary_function_impl<R (__fastcall*)()>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename R>
|
||||||
|
struct is_unary_or_binary_function_impl<R (__cdecl*)()>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
template <typename R>
|
||||||
|
struct is_unary_or_binary_function_impl<R (__cdecl*)(...)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// avoid duplicate definitions of is_unary_or_binary_function_impl
|
||||||
|
#ifndef BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
|
||||||
|
template <typename R, class T0>
|
||||||
|
struct is_unary_or_binary_function_impl<R (*)(T0)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
template <typename R, class T0>
|
||||||
|
struct is_unary_or_binary_function_impl<R (*)(T0...)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#else // BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
|
||||||
|
template <typename R, class T0>
|
||||||
|
struct is_unary_or_binary_function_impl<R (__stdcall*)(T0)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#ifndef _MANAGED
|
||||||
|
|
||||||
|
template <typename R, class T0>
|
||||||
|
struct is_unary_or_binary_function_impl<R (__fastcall*)(T0)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename R, class T0>
|
||||||
|
struct is_unary_or_binary_function_impl<R (__cdecl*)(T0)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
template <typename R, class T0>
|
||||||
|
struct is_unary_or_binary_function_impl<R (__cdecl*)(T0...)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// avoid duplicate definitions of is_unary_or_binary_function_impl
|
||||||
|
#ifndef BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
|
||||||
|
template <typename R, class T0, class T1>
|
||||||
|
struct is_unary_or_binary_function_impl<R (*)(T0, T1)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
template <typename R, class T0, class T1>
|
||||||
|
struct is_unary_or_binary_function_impl<R (*)(T0, T1...)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#else // BOOST_MOVE_TT_TEST_MSC_FUNC_SIGS
|
||||||
|
|
||||||
|
template <typename R, class T0, class T1>
|
||||||
|
struct is_unary_or_binary_function_impl<R (__stdcall*)(T0, T1)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#ifndef _MANAGED
|
||||||
|
|
||||||
|
template <typename R, class T0, class T1>
|
||||||
|
struct is_unary_or_binary_function_impl<R (__fastcall*)(T0, T1)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename R, class T0, class T1>
|
||||||
|
struct is_unary_or_binary_function_impl<R (__cdecl*)(T0, T1)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
template <typename R, class T0, class T1>
|
||||||
|
struct is_unary_or_binary_function_impl<R (__cdecl*)(T0, T1...)>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct is_unary_or_binary_function_impl<T&>
|
||||||
|
{ static const bool value = false; };
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct is_unary_or_binary_function
|
||||||
|
{ static const bool value = is_unary_or_binary_function_impl<T>::value; };
|
||||||
|
|
||||||
} //namespace move_detail {
|
} //namespace move_detail {
|
||||||
} //namespace boost {
|
} //namespace boost {
|
||||||
|
|
||||||
|
26
include/boost/move/detail/workaround.hpp
Normal file
26
include/boost/move/detail/workaround.hpp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (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/interprocess for documentation.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef BOOST_MOVE_DETAIL_WORKAROUND_HPP
|
||||||
|
#define BOOST_MOVE_DETAIL_WORKAROUND_HPP
|
||||||
|
|
||||||
|
#include <boost/intrusive/detail/config_begin.hpp>
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||||
|
#define BOOST_MOVE_PERFECT_FORWARDING
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//Macros for documentation purposes. For code, expands to the argument
|
||||||
|
#define BOOST_MOVE_IMPDEF(TYPE) TYPE
|
||||||
|
#define BOOST_MOVE_SEEDOC(TYPE) TYPE
|
||||||
|
|
||||||
|
#include <boost/intrusive/detail/config_end.hpp>
|
||||||
|
|
||||||
|
#endif //#ifndef BOOST_MOVE_DETAIL_WORKAROUND_HPP
|
149
include/boost/move/make_unique.hpp
Normal file
149
include/boost/move/make_unique.hpp
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Ion Gaztanaga 2006-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_MAKE_UNIQUE_HPP_INCLUDED
|
||||||
|
#define BOOST_MOVE_MAKE_UNIQUE_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include <boost/move/detail/config_begin.hpp>
|
||||||
|
#include <boost/move/detail/workaround.hpp>
|
||||||
|
#include <boost/move/utility_core.hpp>
|
||||||
|
#include <boost/move/unique_ptr.hpp>
|
||||||
|
#include <cstddef> //for std::size_t
|
||||||
|
#include <boost/move/detail/meta_utils.hpp>
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||||
|
#include <boost/preprocessor/iteration/local.hpp>
|
||||||
|
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
||||||
|
#include <boost/preprocessor/repetition/enum.hpp>
|
||||||
|
#include <boost/preprocessor/cat.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//!\file
|
||||||
|
//! Defines "make_unique" functions, which are factories to create instances
|
||||||
|
//! of unique_ptr depending on the passed arguments.
|
||||||
|
//!
|
||||||
|
//! This header can be a bit heavyweight in C++03 compilers due to the use of the
|
||||||
|
//! preprocessor library, that's why it's a a separate header from <tt>unique_ptr.hpp</tt>
|
||||||
|
|
||||||
|
namespace boost{
|
||||||
|
|
||||||
|
#if !defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||||
|
|
||||||
|
namespace move_detail {
|
||||||
|
|
||||||
|
//Compile time switch between
|
||||||
|
//single element, unknown bound array
|
||||||
|
//and known bound array
|
||||||
|
template<class T>
|
||||||
|
struct unique_ptr_if
|
||||||
|
{
|
||||||
|
typedef ::boost::movelib::unique_ptr<T> t_is_not_array;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct unique_ptr_if<T[]>
|
||||||
|
{
|
||||||
|
typedef ::boost::movelib::unique_ptr<T[]> t_is_array_of_unknown_bound;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, std::size_t N>
|
||||||
|
struct unique_ptr_if<T[N]>
|
||||||
|
{
|
||||||
|
typedef void t_is_array_of_known_bound;
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace move_detail {
|
||||||
|
|
||||||
|
#endif //!defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||||
|
|
||||||
|
namespace movelib {
|
||||||
|
|
||||||
|
#if defined(BOOST_MOVE_DOXYGEN_INVOKED) || !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||||
|
|
||||||
|
//! <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(std::forward<Args>(args)...))</tt>.
|
||||||
|
template<class T, class... Args>
|
||||||
|
inline
|
||||||
|
#if defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||||
|
unique_ptr<T>
|
||||||
|
#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)...)); }
|
||||||
|
|
||||||
|
#else
|
||||||
|
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
|
#define BOOST_MOVE_PP_PARAM_LIST(z, n, data) \
|
||||||
|
BOOST_PP_CAT(P, n) && BOOST_PP_CAT(p, n) \
|
||||||
|
//!
|
||||||
|
#else
|
||||||
|
#define BOOST_MOVE_PP_PARAM_LIST(z, n, data) \
|
||||||
|
const BOOST_PP_CAT(P, n) & BOOST_PP_CAT(p, n) \
|
||||||
|
//!
|
||||||
|
#endif //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
|
|
||||||
|
#define BOOST_MOVE_PP_PARAM_FORWARD(z, n, data) \
|
||||||
|
::boost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) ) \
|
||||||
|
//!
|
||||||
|
|
||||||
|
#define BOOST_MOVE_MAX_CONSTRUCTOR_PARAMETERS 10
|
||||||
|
|
||||||
|
#define BOOST_PP_LOCAL_MACRO(n) \
|
||||||
|
template<class T BOOST_PP_ENUM_TRAILING_PARAMS(n, class P) > \
|
||||||
|
typename ::boost::move_detail::unique_ptr_if<T>::t_is_not_array \
|
||||||
|
make_unique(BOOST_PP_ENUM(n, BOOST_MOVE_PP_PARAM_LIST, _)) \
|
||||||
|
{ return unique_ptr<T>(new T(BOOST_PP_ENUM(n, BOOST_MOVE_PP_PARAM_FORWARD, _))); } \
|
||||||
|
//!
|
||||||
|
|
||||||
|
#define BOOST_PP_LOCAL_LIMITS (0, BOOST_MOVE_MAX_CONSTRUCTOR_PARAMETERS)
|
||||||
|
#include BOOST_PP_LOCAL_ITERATE()
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//! <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>.
|
||||||
|
template<class T>
|
||||||
|
inline
|
||||||
|
#if defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||||
|
unique_ptr<T>
|
||||||
|
#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;
|
||||||
|
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 known bound.
|
||||||
|
template<class T, class... Args>
|
||||||
|
#if defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||||
|
unspecified
|
||||||
|
#else
|
||||||
|
typename ::boost::move_detail::unique_ptr_if<T>::t_is_array_of_known_bound
|
||||||
|
#endif
|
||||||
|
make_unique(BOOST_FWD_REF(Args) ...) = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} //namespace movelib {
|
||||||
|
|
||||||
|
} //namespace boost{
|
||||||
|
|
||||||
|
#include <boost/move/detail/config_end.hpp>
|
||||||
|
|
||||||
|
#endif //#ifndef BOOST_MOVE_MAKE_UNIQUE_HPP_INCLUDED
|
1255
include/boost/move/unique_ptr.hpp
Normal file
1255
include/boost/move/unique_ptr.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -84,6 +84,48 @@
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// move_if_not_lvalue_reference()
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline typename ::boost::move_detail::enable_if_c
|
||||||
|
< enable_move_utility_emulation<T>::value &&
|
||||||
|
::boost::move_detail::is_rv<T>::value
|
||||||
|
, T &>::type
|
||||||
|
move_if_not_lvalue_reference(const typename ::boost::move_detail::identity<T>::type &x) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return const_cast<T&>(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline typename ::boost::move_detail::enable_if_c
|
||||||
|
< enable_move_utility_emulation<T>::value &&
|
||||||
|
!::boost::move_detail::is_rv<T>::value &&
|
||||||
|
(::boost::move_detail::is_lvalue_reference<T>::value ||
|
||||||
|
!has_move_emulation_enabled<T>::value)
|
||||||
|
, typename ::boost::move_detail::add_lvalue_reference<T>::type
|
||||||
|
>::type
|
||||||
|
move_if_not_lvalue_reference(typename ::boost::move_detail::remove_reference<T>::type &x) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline typename ::boost::move_detail::enable_if_c
|
||||||
|
< enable_move_utility_emulation<T>::value &&
|
||||||
|
!::boost::move_detail::is_rv<T>::value &&
|
||||||
|
(!::boost::move_detail::is_lvalue_reference<T>::value &&
|
||||||
|
has_move_emulation_enabled<T>::value)
|
||||||
|
, rv<T>&
|
||||||
|
>::type
|
||||||
|
move_if_not_lvalue_reference(typename ::boost::move_detail::remove_reference<T>::type &x) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return move(x);
|
||||||
|
}
|
||||||
|
|
||||||
} //namespace boost
|
} //namespace boost
|
||||||
|
|
||||||
#else //#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
#else //#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||||
@@ -186,12 +228,64 @@
|
|||||||
|
|
||||||
#endif //BOOST_MOVE_DOXYGEN_INVOKED
|
#endif //BOOST_MOVE_DOXYGEN_INVOKED
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// move_if_not_lvalue_reference
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||||
|
template <class T> output_reference move_if_not_lvalue_reference(input_reference) noexcept;
|
||||||
|
#elif defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES)
|
||||||
|
|
||||||
|
//Old move approach, lvalues could bind to rvalue references
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline T&& move_if_not_lvalue_reference(typename ::boost::move_detail::identity<T>::type&& t) BOOST_NOEXCEPT
|
||||||
|
{ return t; }
|
||||||
|
|
||||||
|
#else //Old move
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline T&& move_if_not_lvalue_reference(typename ::boost::move_detail::remove_reference<T>::type& t) BOOST_NOEXCEPT
|
||||||
|
{ return static_cast<T&&>(t); }
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline T&& move_if_not_lvalue_reference(typename ::boost::move_detail::remove_reference<T>::type&& t) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
//"boost::forward<T> error: 'T' is a lvalue reference, can't forward as rvalue.";
|
||||||
|
BOOST_STATIC_ASSERT(!boost::move_detail::is_lvalue_reference<T>::value);
|
||||||
|
return static_cast<T&&>(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //BOOST_MOVE_DOXYGEN_INVOKED
|
||||||
|
|
||||||
} //namespace boost {
|
} //namespace boost {
|
||||||
|
|
||||||
#endif //#if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
|
#endif //#if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
|
||||||
|
|
||||||
#endif //BOOST_NO_CXX11_RVALUE_REFERENCES
|
#endif //BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
|
|
||||||
|
#if !defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||||
|
|
||||||
|
namespace boost{
|
||||||
|
namespace move_detail{
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void swap(T &a, T &b)
|
||||||
|
{
|
||||||
|
T c((::boost::move(a)));
|
||||||
|
a = ::boost::move(b);
|
||||||
|
b = ::boost::move(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace move_detail{
|
||||||
|
} //namespace boost{
|
||||||
|
|
||||||
|
#endif //#if !defined(BOOST_MOVE_DOXYGEN_INVOKED)
|
||||||
|
|
||||||
|
|
||||||
#include <boost/move/detail/config_end.hpp>
|
#include <boost/move/detail/config_end.hpp>
|
||||||
|
|
||||||
#endif //#ifndef BOOST_MOVE_MOVE_UTILITY_CORE_HPP
|
#endif //#ifndef BOOST_MOVE_MOVE_UTILITY_CORE_HPP
|
||||||
|
@@ -67,6 +67,18 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "move_if_noexcept_test", "mo
|
|||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique_ptr_default_deleter_test", "unique_ptr_default_deleter.vcproj", "{C57C25A3-4620-FE08-F8B7-AB673D762B60}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique_ptr_test", "unique_ptr_test.vcproj", "{C57C28A3-4FE0-6208-BF87-A2B61D3A7671}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique_ptr_functions_test", "unique_ptr_functions.vcproj", "{C57C25A3-4620-FE08-F8B7-AB673D762B60}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfiguration) = preSolution
|
GlobalSection(SolutionConfiguration) = preSolution
|
||||||
Debug = Debug
|
Debug = Debug
|
||||||
@@ -143,6 +155,18 @@ Global
|
|||||||
{CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.Build.0 = Debug|Win32
|
{CD57C283-1862-42FE-BF87-B96D3A2A7912}.Debug.Build.0 = Debug|Win32
|
||||||
{CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.ActiveCfg = Release|Win32
|
{CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.ActiveCfg = Release|Win32
|
||||||
{CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.Build.0 = Release|Win32
|
{CD57C283-1862-42FE-BF87-B96D3A2A7912}.Release.Build.0 = Release|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}.Release.ActiveCfg = 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.Build.0 = Debug|Win32
|
||||||
|
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.Release.ActiveCfg = Release|Win32
|
||||||
|
{C57C25A3-4620-FE08-F8B7-AB673D762B60}.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
|
||||||
@@ -151,11 +175,13 @@ Global
|
|||||||
..\..\..\..\boost\move\core.hpp = ..\..\..\..\boost\move\core.hpp
|
..\..\..\..\boost\move\core.hpp = ..\..\..\..\boost\move\core.hpp
|
||||||
..\..\..\..\boost\move\iterator.hpp = ..\..\..\..\boost\move\iterator.hpp
|
..\..\..\..\boost\move\iterator.hpp = ..\..\..\..\boost\move\iterator.hpp
|
||||||
..\..\doc\Jamfile.v2 = ..\..\doc\Jamfile.v2
|
..\..\doc\Jamfile.v2 = ..\..\doc\Jamfile.v2
|
||||||
|
..\..\..\..\boost\move\make_unique.hpp = ..\..\..\..\boost\move\make_unique.hpp
|
||||||
..\..\..\..\boost\move\detail\meta_utils.hpp = ..\..\..\..\boost\move\detail\meta_utils.hpp
|
..\..\..\..\boost\move\detail\meta_utils.hpp = ..\..\..\..\boost\move\detail\meta_utils.hpp
|
||||||
..\..\..\..\boost\move\move.hpp = ..\..\..\..\boost\move\move.hpp
|
..\..\..\..\boost\move\move.hpp = ..\..\..\..\boost\move\move.hpp
|
||||||
..\..\doc\move.qbk = ..\..\doc\move.qbk
|
..\..\doc\move.qbk = ..\..\doc\move.qbk
|
||||||
..\..\..\..\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\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
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="3"
|
||||||
DisableLanguageExtensions="TRUE"
|
DisableLanguageExtensions="FALSE"
|
||||||
TreatWChar_tAsBuiltInType="TRUE"
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
ForceConformanceInForLoopScope="TRUE"
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="3"
|
||||||
DisableLanguageExtensions="TRUE"
|
DisableLanguageExtensions="FALSE"
|
||||||
TreatWChar_tAsBuiltInType="TRUE"
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
ForceConformanceInForLoopScope="TRUE"
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="3"
|
||||||
DisableLanguageExtensions="TRUE"
|
DisableLanguageExtensions="FALSE"
|
||||||
TreatWChar_tAsBuiltInType="TRUE"
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
ForceConformanceInForLoopScope="TRUE"
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="3"
|
||||||
DisableLanguageExtensions="TRUE"
|
DisableLanguageExtensions="FALSE"
|
||||||
TreatWChar_tAsBuiltInType="TRUE"
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
ForceConformanceInForLoopScope="TRUE"
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="3"
|
||||||
DisableLanguageExtensions="TRUE"
|
DisableLanguageExtensions="FALSE"
|
||||||
TreatWChar_tAsBuiltInType="TRUE"
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
ForceConformanceInForLoopScope="TRUE"
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
|
135
proj/vc7ide/unique_ptr_default_deleter.vcproj
Normal file
135
proj/vc7ide/unique_ptr_default_deleter.vcproj
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="7.10"
|
||||||
|
Name="unique_ptr_default_deleter_test"
|
||||||
|
ProjectGUID="{C57C25A3-4620-FE08-F8B7-AB673D762B60}"
|
||||||
|
Keyword="Win32Proj">
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"/>
|
||||||
|
</Platforms>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Debug"
|
||||||
|
IntermediateDirectory="Debug/unique_ptr_default_deleter_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_default_deleter_test_d.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/unique_ptr_default_deleter_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_default_deleter_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_default_deleter_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="{73495AA1-5A6C-3E57-16AC-542F7F2242B9}">
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\test\unique_ptr_default_deleter.cpp">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
134
proj/vc7ide/unique_ptr_functions.vcproj
Normal file
134
proj/vc7ide/unique_ptr_functions.vcproj
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="7.10"
|
||||||
|
Name="unique_ptr_functions_test"
|
||||||
|
ProjectGUID="{C57C25A3-4620-FE08-F8B7-AB673D762B60}"
|
||||||
|
Keyword="Win32Proj">
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"/>
|
||||||
|
</Platforms>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Debug"
|
||||||
|
IntermediateDirectory="Debug/unique_ptr_functions_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_functions_test_d.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/unique_ptr_functions_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_functions_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_functions_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="{73495AA1-5A6C-3E57-16AC-542F7F2242B9}">
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\test\unique_ptr_functions.cpp">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
135
proj/vc7ide/unique_ptr_test.vcproj
Normal file
135
proj/vc7ide/unique_ptr_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_test"
|
||||||
|
ProjectGUID="{C57C28A3-4FE0-6208-BF87-A2B61D3A7671}"
|
||||||
|
Keyword="Win32Proj">
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"/>
|
||||||
|
</Platforms>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Debug"
|
||||||
|
IntermediateDirectory="Debug/unique_ptr_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_test_d.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/unique_ptr_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_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_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-2A2754202BFA}">
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\test\unique_ptr.cpp">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
@@ -1,6 +1,7 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// (C) Copyright David Abrahams, Vicente Botet, Ion Gaztanaga 2009.
|
// (C) Copyright David Abrahams, Vicente Botet, Ion Gaztanaga 2009.
|
||||||
|
// (C) Copyright Ion Gaztanaga 2009-2014.
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// (C) Copyright Antony Polukhin 2014.
|
// (C) Copyright Antony Polukhin 2014.
|
||||||
|
// (C) Copyright Ion Gaztanaga 2014.
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
1907
test/unique_ptr.cpp
Normal file
1907
test/unique_ptr.cpp
Normal file
File diff suppressed because it is too large
Load Diff
134
test/unique_ptr_default_deleter.cpp
Normal file
134
test/unique_ptr_default_deleter.cpp
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (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/detail/config_begin.hpp>
|
||||||
|
|
||||||
|
#include <boost/move/unique_ptr.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.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_dltr_dflt_convert_ctor
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace bml = ::boost::movelib;
|
||||||
|
|
||||||
|
struct A
|
||||||
|
{
|
||||||
|
static int count;
|
||||||
|
A() {++count;}
|
||||||
|
A(const A&) {++count;}
|
||||||
|
virtual ~A() {--count;}
|
||||||
|
};
|
||||||
|
|
||||||
|
int A::count = 0;
|
||||||
|
|
||||||
|
struct B
|
||||||
|
: public A
|
||||||
|
{
|
||||||
|
static int count;
|
||||||
|
B() {++count;}
|
||||||
|
B(const B&) {++count;}
|
||||||
|
virtual ~B() {--count;}
|
||||||
|
};
|
||||||
|
|
||||||
|
int B::count = 0;
|
||||||
|
|
||||||
|
void reset_counters()
|
||||||
|
{ A::count = B::count = 0; }
|
||||||
|
|
||||||
|
namespace unique_ptr_dltr_dflt_convert_ctor{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single element deleter
|
||||||
|
{
|
||||||
|
reset_counters();
|
||||||
|
bml::default_delete<B> d2;
|
||||||
|
bml::default_delete<A> 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 = d2;
|
||||||
|
const A* p = new const A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
d1(p);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_dltr_dflt_convert_ctor{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_ptr_dltr_dflt_default
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_ptr_dltr_dflt_default{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
//Single element deleter
|
||||||
|
reset_counters();
|
||||||
|
bml::default_delete<A> d;
|
||||||
|
A* p = new A;
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
d(p);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
//Array element deleter
|
||||||
|
reset_counters();
|
||||||
|
bml::default_delete<A[]> d;
|
||||||
|
A* p = new A[2];
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
d(p);
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_ptr_dltr_dflt_default{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// main
|
||||||
|
////////////////////////////////
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
unique_ptr_dltr_dflt_convert_ctor::test();
|
||||||
|
unique_ptr_dltr_dflt_default::test();
|
||||||
|
|
||||||
|
//Test results
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <boost/move/detail/config_end.hpp>
|
174
test/unique_ptr_functions.cpp
Normal file
174
test/unique_ptr_functions.cpp
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (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/detail/config_begin.hpp>
|
||||||
|
#include <boost/move/make_unique.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
struct A
|
||||||
|
{
|
||||||
|
int a, b, c;
|
||||||
|
static int count;
|
||||||
|
A() : a (999), b(1000), c(1001) {++count;}
|
||||||
|
A(int a) : a (a), b(1000), c(1001) {++count;}
|
||||||
|
A(int a, int b) : a (a), b(b), c(1001) {++count;}
|
||||||
|
A(int a, int b, int c) : a (a), b(b), c(c) {++count;}
|
||||||
|
A(const A&) {++count;}
|
||||||
|
virtual ~A() {--count;}
|
||||||
|
};
|
||||||
|
|
||||||
|
int A::count = 0;
|
||||||
|
|
||||||
|
struct B
|
||||||
|
: public A
|
||||||
|
{
|
||||||
|
static int count;
|
||||||
|
B() {++count;}
|
||||||
|
B(const B&) {++count;}
|
||||||
|
virtual ~B() {--count;}
|
||||||
|
};
|
||||||
|
|
||||||
|
int B::count = 0;
|
||||||
|
|
||||||
|
void reset_counters()
|
||||||
|
{ A::count = B::count = 0; }
|
||||||
|
|
||||||
|
namespace bml = ::boost::movelib;
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// make_unique_single
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace make_unique_single{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single element deleter
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> p(bml::make_unique<A>());
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(p->a == 999);
|
||||||
|
BOOST_TEST(p->b == 1000);
|
||||||
|
BOOST_TEST(p->c == 1001);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> p(bml::make_unique<A>(0));
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(p->a == 0);
|
||||||
|
BOOST_TEST(p->b == 1000);
|
||||||
|
BOOST_TEST(p->c == 1001);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> p(bml::make_unique<A>(0, 1));
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(p->a == 0);
|
||||||
|
BOOST_TEST(p->b == 1);
|
||||||
|
BOOST_TEST(p->c == 1001);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> p(bml::make_unique<A>(0, 1, 2));
|
||||||
|
BOOST_TEST(A::count == 1);
|
||||||
|
BOOST_TEST(p->a == 0);
|
||||||
|
BOOST_TEST(p->b == 1);
|
||||||
|
BOOST_TEST(p->c == 2);
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace make_unique_single{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// make_unique_single
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace make_unique_array{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single element deleter
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A[]> p(bml::make_unique<A[]>(10));
|
||||||
|
BOOST_TEST(A::count == 10);
|
||||||
|
for(int i = 0; i != 10; ++i){
|
||||||
|
BOOST_TEST(p[i].a == 999);
|
||||||
|
BOOST_TEST(p[i].b == 1000);
|
||||||
|
BOOST_TEST(p[i].c == 1001);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace make_unique_array{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// unique_compare
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
namespace unique_compare{
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
//Single element deleter
|
||||||
|
reset_counters();
|
||||||
|
{
|
||||||
|
bml::unique_ptr<A> pa(bml::make_unique<A>());
|
||||||
|
bml::unique_ptr<A> pb(bml::make_unique<A>());
|
||||||
|
BOOST_TEST(A::count == 2);
|
||||||
|
|
||||||
|
//Take references to less and greater
|
||||||
|
bml::unique_ptr<A> &rpl = pa < pb ? pa : pb;
|
||||||
|
bml::unique_ptr<A> &rpg = pa < pb ? pb : pa;
|
||||||
|
|
||||||
|
//Now test operations with .get()
|
||||||
|
|
||||||
|
//Equal
|
||||||
|
BOOST_TEST(rpl == rpl && rpl.get() == rpl.get());
|
||||||
|
BOOST_TEST(!(rpl == rpg) && !(rpl.get() != rpg.get()));
|
||||||
|
//Unequal
|
||||||
|
BOOST_TEST(rpl != rpg && rpl.get() != rpg.get());
|
||||||
|
BOOST_TEST(!(rpl != rpl) && !(rpl.get() != rpl.get()));
|
||||||
|
//Less
|
||||||
|
BOOST_TEST(rpl < rpg && rpl.get() < rpg.get());
|
||||||
|
BOOST_TEST(!(rpl < rpg) && !(rpl.get() < rpg.get()));
|
||||||
|
//Greater
|
||||||
|
BOOST_TEST(rpg > rpl && rpg.get() > rpl.get());
|
||||||
|
BOOST_TEST(!(rpg > rpg) && !(rpg.get() > rpl.get()));
|
||||||
|
//Less or equal
|
||||||
|
BOOST_TEST(rpl <= rpg && rpl.get() <= rpg.get());
|
||||||
|
BOOST_TEST(rpl <= rpl && rpl.get() <= rpl.get());
|
||||||
|
BOOST_TEST(!(rpg <= rpl) && !(rpg.get() < rpl.get()));
|
||||||
|
//Greater or equal
|
||||||
|
BOOST_TEST(rpg >= rpl && rpg.get() >= rpl.get());
|
||||||
|
BOOST_TEST(rpg >= rpg && rpg.get() >= rpg.get());
|
||||||
|
BOOST_TEST(!(rpl >= rpg) && !(rpl.get() < rpg.get()));
|
||||||
|
}
|
||||||
|
BOOST_TEST(A::count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace unique_compare{
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
// main
|
||||||
|
////////////////////////////////
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
make_unique_single::test();
|
||||||
|
make_unique_array::test();
|
||||||
|
|
||||||
|
//Test results
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <boost/move/detail/config_end.hpp>
|
Reference in New Issue
Block a user