mirror of
https://github.com/boostorg/move.git
synced 2025-08-02 05:44:25 +02:00
Merge branch 'develop'
This commit is contained in:
@@ -757,10 +757,11 @@ Many thanks to all boosters that have tested, reviewed and improved the library.
|
||||
|
||||
[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 `unique_ptr` smart pointer. 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.
|
||||
* Fixed bugs:
|
||||
* [@https://svn.boost.org/trac/boost/ticket/9785 Trac #9785: ['"Compiler warning with intel icc in boost/move/core.hpp"]],
|
||||
* [@https://github.com/boostorg/move/pull/3 Git Pull #3: ['"Don't delete copy constructor when rvalue references are disabled"]],
|
||||
|
||||
[endsect]
|
||||
|
||||
|
@@ -9,7 +9,7 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/move/detail/config_begin.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
|
||||
//[clone_ptr_base_derived
|
||||
class Base
|
||||
|
@@ -12,7 +12,7 @@
|
||||
#include <boost/move/detail/config_begin.hpp>
|
||||
|
||||
//[construct_forward_example
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <iostream>
|
||||
|
||||
class copyable_only_tester
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
//[file_descriptor_def
|
||||
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
class file_descriptor
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
#include <boost/move/detail/config_begin.hpp>
|
||||
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/move/iterator.hpp>
|
||||
#include <boost/detail/no_exceptions_support.hpp>
|
||||
|
||||
@@ -271,4 +271,4 @@ inline F copy_or_move(I f, I l, F r
|
||||
|
||||
#include <boost/move/detail/config_end.hpp>
|
||||
|
||||
#endif //#ifndef BOOST_MOVE_MOVE_HPP
|
||||
#endif //#ifndef BOOST_MOVE_ALGORITHM_HPP
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
//boost_move_no_copy_constructor_or_assign typedef
|
||||
//used to detect noncopyable types for other Boost libraries.
|
||||
#if defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
|
||||
#if defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#define BOOST_MOVE_IMPL_NO_COPY_CTOR_OR_ASSIGN(TYPE) \
|
||||
private:\
|
||||
TYPE(TYPE &);\
|
||||
@@ -87,7 +87,9 @@
|
||||
|
||||
template <class T>
|
||||
struct is_rv
|
||||
: ::boost::move_detail::is_rv_impl<T>
|
||||
//Derive from integral constant because some Boost code assummes it has
|
||||
//a "type" internal typedef
|
||||
: integral_constant<bool, ::boost::move_detail::is_rv_impl<T>::value >
|
||||
{};
|
||||
|
||||
} //namespace move_detail {
|
||||
|
@@ -7,7 +7,9 @@
|
||||
// See http://www.boost.org/libs/move for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
#include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning (push)
|
||||
|
@@ -12,7 +12,7 @@
|
||||
#ifndef BOOST_MOVE_MOVE_HELPERS_HPP
|
||||
#define BOOST_MOVE_MOVE_HELPERS_HPP
|
||||
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/move/detail/meta_utils.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
@@ -15,7 +15,7 @@
|
||||
#define BOOST_MOVE_ITERATOR_HPP
|
||||
|
||||
#include <boost/move/detail/config_begin.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <iterator> //std::iterator
|
||||
|
||||
namespace boost {
|
||||
@@ -177,7 +177,6 @@ inline move_iterator<It> make_move_iterator(const It &it)
|
||||
//! back of a container
|
||||
template <typename C> // C models Container
|
||||
class back_move_insert_iterator
|
||||
: public std::iterator<std::output_iterator_tag, void, void, void, void>
|
||||
{
|
||||
C* container_m;
|
||||
|
||||
@@ -185,6 +184,9 @@ class back_move_insert_iterator
|
||||
typedef C container_type;
|
||||
typedef typename C::value_type value_type;
|
||||
typedef typename C::reference reference;
|
||||
typedef typename C::pointer pointer;
|
||||
typedef typename C::difference_type difference_type;
|
||||
typedef std::output_iterator_tag iterator_category;
|
||||
|
||||
explicit back_move_insert_iterator(C& x) : container_m(&x) { }
|
||||
|
||||
@@ -217,7 +219,6 @@ inline back_move_insert_iterator<C> back_move_inserter(C& x)
|
||||
//! front of a container
|
||||
template <typename C> // C models Container
|
||||
class front_move_insert_iterator
|
||||
: public std::iterator<std::output_iterator_tag, void, void, void, void>
|
||||
{
|
||||
C* container_m;
|
||||
|
||||
@@ -225,6 +226,9 @@ public:
|
||||
typedef C container_type;
|
||||
typedef typename C::value_type value_type;
|
||||
typedef typename C::reference reference;
|
||||
typedef typename C::pointer pointer;
|
||||
typedef typename C::difference_type difference_type;
|
||||
typedef std::output_iterator_tag iterator_category;
|
||||
|
||||
explicit front_move_insert_iterator(C& x) : container_m(&x) { }
|
||||
|
||||
@@ -254,7 +258,6 @@ inline front_move_insert_iterator<C> front_move_inserter(C& x)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
template <typename C> // C models Container
|
||||
class move_insert_iterator
|
||||
: public std::iterator<std::output_iterator_tag, void, void, void, void>
|
||||
{
|
||||
C* container_m;
|
||||
typename C::iterator pos_;
|
||||
@@ -263,6 +266,9 @@ class move_insert_iterator
|
||||
typedef C container_type;
|
||||
typedef typename C::value_type value_type;
|
||||
typedef typename C::reference reference;
|
||||
typedef typename C::pointer pointer;
|
||||
typedef typename C::difference_type difference_type;
|
||||
typedef std::output_iterator_tag iterator_category;
|
||||
|
||||
explicit move_insert_iterator(C& x, typename C::iterator pos)
|
||||
: container_m(&x), pos_(pos)
|
||||
|
@@ -9,7 +9,7 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/move/detail/config_begin.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include "../example/movable.hpp"
|
||||
#include "../example/copymovable.hpp"
|
||||
|
@@ -8,7 +8,7 @@
|
||||
// See http://www.boost.org/libs/move for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/move/detail/meta_utils.hpp>
|
||||
#include <cassert>
|
||||
#include <new>
|
||||
|
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <boost/move/detail/config_begin.hpp>
|
||||
#include <iostream>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#ifdef NO_MOVE
|
||||
# undef BOOST_COPY_ASSIGN_REF
|
||||
@@ -12,7 +13,7 @@
|
||||
# define BOOST_COPYABLE_AND_MOVABLE(X)
|
||||
# define MOVE(x) (x)
|
||||
#else
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
# define MOVE(x) boost::move(x)
|
||||
#endif
|
||||
|
||||
@@ -73,9 +74,12 @@ unsigned X::instances = 0;
|
||||
stmt; \
|
||||
} \
|
||||
unsigned const n = X::copies - old_copies; \
|
||||
if (n > max) \
|
||||
volatile unsigned const minv(min), maxv(max); \
|
||||
BOOST_TEST(n <= maxv); \
|
||||
if (n > maxv) \
|
||||
std::cout << "*** max is too low or compiler is buggy ***\n"; \
|
||||
if (n < min) \
|
||||
BOOST_TEST(n >= minv); \
|
||||
if (n < minv) \
|
||||
std::cout << "*** min is too high or compiler is buggy ***\n"; \
|
||||
\
|
||||
std::cout << "-----------\n" \
|
||||
@@ -84,7 +88,7 @@ unsigned X::instances = 0;
|
||||
<< max - n << "/" << max - min \
|
||||
<< " possible elisions performed\n\n"; \
|
||||
\
|
||||
if (n > min) \
|
||||
if (n > minv) \
|
||||
std::cout << "*** " << n - min \
|
||||
<< " possible elisions missed! ***\n"; \
|
||||
}
|
||||
@@ -105,7 +109,7 @@ struct trace
|
||||
char const* m_name;
|
||||
};
|
||||
|
||||
void sink(X a)
|
||||
void sink(X)
|
||||
{
|
||||
trace t("sink");
|
||||
}
|
||||
@@ -146,28 +150,28 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
(void)argv;
|
||||
// Double parens prevent "most vexing parse"
|
||||
CHECK_COPIES( X a(( lvalue() )), 1, 1, "Direct initialization from lvalue");
|
||||
CHECK_COPIES( X a(( rvalue() )), 0, 1, "Direct initialization from rvalue");
|
||||
CHECK_COPIES( X a(( lvalue() )), 1U, 1U, "Direct initialization from lvalue");
|
||||
CHECK_COPIES( X a(( rvalue() )), 0U, 1U, "Direct initialization from rvalue");
|
||||
|
||||
CHECK_COPIES( X a = lvalue(), 1, 1, "Copy initialization from lvalue" );
|
||||
CHECK_COPIES( X a = rvalue(), 0, 1, "Copy initialization from rvalue" );
|
||||
CHECK_COPIES( X a = lvalue(), 1U, 1U, "Copy initialization from lvalue" );
|
||||
CHECK_COPIES( X a = rvalue(), 0U, 1U, "Copy initialization from rvalue" );
|
||||
|
||||
CHECK_COPIES( sink( lvalue() ), 1, 1, "Pass lvalue by value" );
|
||||
CHECK_COPIES( sink( rvalue() ), 0, 1, "Pass rvalue by value" );
|
||||
CHECK_COPIES( sink( lvalue() ), 1U, 1U, "Pass lvalue by value" );
|
||||
CHECK_COPIES( sink( rvalue() ), 0U, 1U, "Pass rvalue by value" );
|
||||
|
||||
CHECK_COPIES( nrvo_source(), 0, 1, "Named return value optimization (NRVO)" );
|
||||
CHECK_COPIES( urvo_source(), 0, 1, "Unnamed return value optimization (URVO)" );
|
||||
CHECK_COPIES( nrvo_source(), 0U, 1U, "Named return value optimization (NRVO)" );
|
||||
CHECK_COPIES( urvo_source(), 0U, 1U, "Unnamed return value optimization (URVO)" );
|
||||
|
||||
// Just to prove these things compose properly
|
||||
CHECK_COPIES( X a(urvo_source()), 0, 2, "Return value used as ctor arg" );
|
||||
CHECK_COPIES( X a(urvo_source()), 0U, 2U, "Return value used as ctor arg" );
|
||||
|
||||
// Expect to miss one possible elision here
|
||||
CHECK_COPIES( identity( rvalue() ), 0, 2, "Return rvalue passed by value" );
|
||||
CHECK_COPIES( identity( rvalue() ), 0U, 2U, "Return rvalue passed by value" );
|
||||
|
||||
// Expect to miss an elision in at least one of the following lines
|
||||
CHECK_COPIES( X a = ternary( argc == 1000 ), 0, 2, "Return result of ternary operation" );
|
||||
CHECK_COPIES( X a = ternary( argc != 1000 ), 0, 2, "Return result of ternary operation again" );
|
||||
return 0;
|
||||
CHECK_COPIES( X a = ternary( argc == 1000 ), 0U, 2U, "Return result of ternary operation" );
|
||||
CHECK_COPIES( X a = ternary( argc != 1000 ), 0U, 2U, "Return result of ternary operation again" );
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#include <boost/move/detail/config_end.hpp>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
//Since RVO is better than move-construction,
|
||||
//avoid copy constructor overloading.
|
||||
#include <boost/move/detail/config_begin.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <iostream>
|
||||
|
||||
bool moved = false;
|
||||
|
@@ -10,7 +10,7 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/move/detail/config_begin.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include "../example/movable.hpp"
|
||||
#include "../example/copymovable.hpp"
|
||||
#include <boost/static_assert.hpp>
|
||||
|
@@ -47,8 +47,8 @@ struct B
|
||||
: public A
|
||||
{
|
||||
static int count;
|
||||
B() {++count;}
|
||||
B(const B&) {++count;}
|
||||
B() : A() {++count;}
|
||||
B(const B&) : A() {++count;}
|
||||
virtual ~B() {--count;}
|
||||
};
|
||||
|
||||
|
@@ -31,8 +31,8 @@ struct B
|
||||
: public A
|
||||
{
|
||||
static int count;
|
||||
B() {++count;}
|
||||
B(const B&) {++count;}
|
||||
B() : A() {++count;}
|
||||
B(const B&) : A() {++count;}
|
||||
virtual ~B() {--count;}
|
||||
};
|
||||
|
||||
@@ -218,25 +218,25 @@ void test()
|
||||
BOOST_TEST(!(pb != 0));
|
||||
BOOST_TEST(!(0 != pb));
|
||||
//Less
|
||||
BOOST_TEST((pa < 0) == (pa.get() < 0));
|
||||
BOOST_TEST((0 < pa) == (0 < pa.get()));
|
||||
BOOST_TEST((pb < 0) == (pb.get() < 0));
|
||||
BOOST_TEST((0 < pb) == (0 < pb.get()));
|
||||
BOOST_TEST((pa < 0) == (pa.get() < (A*)0));
|
||||
BOOST_TEST((0 < pa) == ((A*)0 < pa.get()));
|
||||
BOOST_TEST((pb < 0) == (pb.get() < (A*)0));
|
||||
BOOST_TEST((0 < pb) == ((A*)0 < pb.get()));
|
||||
//Greater
|
||||
BOOST_TEST((pa > 0) == (pa.get() > 0));
|
||||
BOOST_TEST((0 > pa) == (0 > pa.get()));
|
||||
BOOST_TEST((pb > 0) == (pb.get() > 0));
|
||||
BOOST_TEST((0 > pb) == (0 > pb.get()));
|
||||
BOOST_TEST((pa > 0) == (pa.get() > (A*)0));
|
||||
BOOST_TEST((0 > pa) == ((A*)0 > pa.get()));
|
||||
BOOST_TEST((pb > 0) == (pb.get() > (A*)0));
|
||||
BOOST_TEST((0 > pb) == ((A*)0 > pb.get()));
|
||||
//Less or equal
|
||||
BOOST_TEST((pa <= 0) == (pa.get() <= 0));
|
||||
BOOST_TEST((0 <= pa) == (0 <= pa.get()));
|
||||
BOOST_TEST((pb <= 0) == (pb.get() <= 0));
|
||||
BOOST_TEST((0 <= pb) == (0 <= pb.get()));
|
||||
BOOST_TEST((pa <= 0) == (pa.get() <= (A*)0));
|
||||
BOOST_TEST((0 <= pa) == ((A*)0 <= pa.get()));
|
||||
BOOST_TEST((pb <= 0) == (pb.get() <= (A*)0));
|
||||
BOOST_TEST((0 <= pb) == ((A*)0 <= pb.get()));
|
||||
//Greater or equal
|
||||
BOOST_TEST((pa >= 0) == (pa.get() >= 0));
|
||||
BOOST_TEST((0 >= pa) == (0 >= pa.get()));
|
||||
BOOST_TEST((pb >= 0) == (pb.get() >= 0));
|
||||
BOOST_TEST((0 >= pb) == (0 >= pb.get()));
|
||||
BOOST_TEST((pa >= 0) == (pa.get() >= (A*)0));
|
||||
BOOST_TEST((0 >= pa) == ((A*)0 >= pa.get()));
|
||||
BOOST_TEST((pb >= 0) == (pb.get() >= (A*)0));
|
||||
BOOST_TEST((0 >= pb) == ((A*)0 >= pb.get()));
|
||||
}
|
||||
BOOST_TEST(A::count == 0);
|
||||
}
|
||||
@@ -270,25 +270,25 @@ void test()
|
||||
BOOST_TEST(!(pb != nullptr));
|
||||
BOOST_TEST(!(nullptr != pb));
|
||||
//Less
|
||||
BOOST_TEST((pa < nullptr) == (pa.get() < nullptr));
|
||||
BOOST_TEST((nullptr < pa) == (nullptr < pa.get()));
|
||||
BOOST_TEST((pb < nullptr) == (pb.get() < nullptr));
|
||||
BOOST_TEST((nullptr < pb) == (nullptr < pb.get()));
|
||||
BOOST_TEST((pa < nullptr) == (pa.get() < (A*)nullptr));
|
||||
BOOST_TEST((nullptr < pa) == ((A*)nullptr < pa.get()));
|
||||
BOOST_TEST((pb < nullptr) == (pb.get() < (A*)nullptr));
|
||||
BOOST_TEST((nullptr < pb) == ((A*)nullptr < pb.get()));
|
||||
//Greater
|
||||
BOOST_TEST((pa > nullptr) == (pa.get() > nullptr));
|
||||
BOOST_TEST((nullptr > pa) == (nullptr > pa.get()));
|
||||
BOOST_TEST((pb > nullptr) == (pb.get() > nullptr));
|
||||
BOOST_TEST((nullptr > pb) == (nullptr > pb.get()));
|
||||
BOOST_TEST((pa > nullptr) == (pa.get() > (A*)nullptr));
|
||||
BOOST_TEST((nullptr > pa) == ((A*)nullptr > pa.get()));
|
||||
BOOST_TEST((pb > nullptr) == (pb.get() > (A*)nullptr));
|
||||
BOOST_TEST((nullptr > pb) == ((A*)nullptr > pb.get()));
|
||||
//Less or equal
|
||||
BOOST_TEST((pa <= nullptr) == (pa.get() <= nullptr));
|
||||
BOOST_TEST((nullptr <= pa) == (nullptr <= pa.get()));
|
||||
BOOST_TEST((pb <= nullptr) == (pb.get() <= nullptr));
|
||||
BOOST_TEST((nullptr <= pb) == (nullptr <= pb.get()));
|
||||
BOOST_TEST((pa <= nullptr) == (pa.get() <= (A*)nullptr));
|
||||
BOOST_TEST((nullptr <= pa) == ((A*)nullptr <= pa.get()));
|
||||
BOOST_TEST((pb <= nullptr) == (pb.get() <= (A*)nullptr));
|
||||
BOOST_TEST((nullptr <= pb) == ((A*)nullptr <= pb.get()));
|
||||
//Greater or equal
|
||||
BOOST_TEST((pa >= nullptr) == (pa.get() >= nullptr));
|
||||
BOOST_TEST((nullptr >= pa) == (nullptr >= pa.get()));
|
||||
BOOST_TEST((pb >= nullptr) == (pb.get() >= nullptr));
|
||||
BOOST_TEST((nullptr >= pb) == (nullptr >= pb.get()));
|
||||
BOOST_TEST((pa >= nullptr) == (pa.get() >= (A*)nullptr));
|
||||
BOOST_TEST((nullptr >= pa) == ((A*)nullptr >= pa.get()));
|
||||
BOOST_TEST((pb >= nullptr) == (pb.get() >= (A*)nullptr));
|
||||
BOOST_TEST((nullptr >= pb) == ((A*)nullptr >= pb.get()));
|
||||
}
|
||||
BOOST_TEST(A::count == 0);
|
||||
#endif //#if !defined(BOOST_NO_CXX11_NULLPTR)
|
||||
|
@@ -173,8 +173,8 @@ struct B
|
||||
: public A
|
||||
{
|
||||
static int count;
|
||||
B() {++count;}
|
||||
B(const B&) {++count;}
|
||||
B() : A() {++count;}
|
||||
B(const B &b) : A(b) {++count;}
|
||||
virtual ~B() {--count;}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user