mirror of
https://github.com/boostorg/move.git
synced 2025-07-29 20:07:13 +02:00
Updated documentation and tests to Boost.Container
[SVN r74156]
This commit is contained in:
@ -18,12 +18,11 @@
|
||||
]
|
||||
]
|
||||
|
||||
[important To be able to use containers of movable-only values you will need to use containers supporting move sematantics,
|
||||
like [*Boost.Interprocess] containers]
|
||||
[important To be able to use containers of movable-only values you will need to use containers
|
||||
supporting move semantics, like [*Boost.Container] containers]
|
||||
|
||||
[note Tested compilers: MSVC-7.1, 8.0, 9.0, GCC 4.3-MinGW in C++03 and C++0x modes, Intel 10.1]
|
||||
|
||||
|
||||
[section:what_is_boost_move What is Boost.Move?]
|
||||
|
||||
Rvalue references are a major C++0x feature, enabling move semantics for C++ values. However, we
|
||||
@ -285,7 +284,7 @@ movable and copyable types are more efficiently handled if those containers
|
||||
internally use move semantics instead of copy semantics.
|
||||
If the container needs to "change the location" of an element
|
||||
internally (e.g. vector reallocation) it will move the element instead of copying it.
|
||||
[*Boost.Interprocess] containers are move-aware so you can write the following:
|
||||
[*Boost.Container] containers are move-aware so you can write the following:
|
||||
|
||||
[file_descriptor_example]
|
||||
|
||||
|
@ -56,7 +56,7 @@ class file_descriptor
|
||||
//]
|
||||
|
||||
//[file_descriptor_example
|
||||
#include <boost/interprocess/containers/vector.hpp>
|
||||
#include <boost/container/vector.hpp>
|
||||
#include <cassert>
|
||||
|
||||
//Remember: 'file_descriptor' is NOT copyable, but it
|
||||
@ -72,7 +72,7 @@ int main()
|
||||
assert(!fd.empty());
|
||||
|
||||
//Now move fd into a vector
|
||||
boost::interprocess::vector<file_descriptor> v;
|
||||
boost::container::vector<file_descriptor> v;
|
||||
v.push_back(boost::move(fd));
|
||||
|
||||
//Check ownership has been transferred
|
||||
@ -81,7 +81,7 @@ int main()
|
||||
|
||||
//Compilation error if uncommented since file_descriptor is not copyable
|
||||
//and vector copy construction requires value_type's copy constructor:
|
||||
//boost::interprocess::vector<file_descriptor> v2(v);
|
||||
//boost::container::vector<file_descriptor> v2(v);
|
||||
return 0;
|
||||
}
|
||||
//]
|
||||
|
@ -10,11 +10,11 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//[move_inserter_example
|
||||
#include <boost/interprocess/containers/list.hpp>
|
||||
#include <boost/container/list.hpp>
|
||||
#include "movable.hpp"
|
||||
#include <cassert>
|
||||
|
||||
using namespace ::boost::interprocess;
|
||||
using namespace ::boost::container;
|
||||
|
||||
typedef list<movable> list_t;
|
||||
typedef list_t::iterator l_iterator;
|
||||
|
@ -10,13 +10,13 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//[move_iterator_example
|
||||
#include <boost/interprocess/containers/vector.hpp>
|
||||
#include <boost/container/vector.hpp>
|
||||
#include "movable.hpp"
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ::boost::interprocess;
|
||||
using namespace ::boost::container;
|
||||
|
||||
//Create a vector with 10 default constructed objects
|
||||
vector<movable> v(10);
|
||||
|
@ -9,9 +9,9 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/interprocess/containers/vector.hpp>
|
||||
#include <boost/interprocess/containers/list.hpp>
|
||||
#include <boost/interprocess/containers/stable_vector.hpp>
|
||||
#include <boost/container/deque.hpp>
|
||||
#include <boost/container/list.hpp>
|
||||
#include <boost/container/stable_vector.hpp>
|
||||
#include "../example/movable.hpp"
|
||||
|
||||
template<class Container>
|
||||
@ -46,15 +46,15 @@ int move_test()
|
||||
|
||||
int main()
|
||||
{
|
||||
namespace bi = ::boost::interprocess;
|
||||
namespace bc = ::boost::container;
|
||||
|
||||
if(move_test< bi::vector<movable> >()){
|
||||
if(move_test< bc::vector<movable> >()){
|
||||
return 1;
|
||||
}
|
||||
if(move_test< bi::list<movable> >()){
|
||||
if(move_test< bc::list<movable> >()){
|
||||
return 1;
|
||||
}
|
||||
if(move_test< bi::stable_vector<movable> >()){
|
||||
if(move_test< bc::stable_vector<movable> >()){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -9,15 +9,15 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/interprocess/containers/vector.hpp>
|
||||
#include <boost/container/vector.hpp>
|
||||
#include "../example/movable.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
namespace bi = ::boost::interprocess;
|
||||
namespace bc = ::boost::container;
|
||||
//Default construct 10 movable objects
|
||||
bi::vector<movable> v(10);
|
||||
bi::vector<movable> v2(10);
|
||||
bc::vector<movable> v(10);
|
||||
bc::vector<movable> v2(10);
|
||||
|
||||
//Move to v2
|
||||
boost::move(v.begin(), v.end(), v2.begin());
|
||||
|
@ -10,14 +10,14 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/interprocess/containers/vector.hpp>
|
||||
#include <boost/container/vector.hpp>
|
||||
#include "../example/movable.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
namespace bi = ::boost::interprocess;
|
||||
namespace bc = ::boost::container;
|
||||
//Default construct 10 movable objects
|
||||
bi::vector<movable> v(10);
|
||||
bc::vector<movable> v(10);
|
||||
|
||||
//Test default constructed value
|
||||
if(v[0].moved()){
|
||||
@ -25,7 +25,7 @@ int main()
|
||||
}
|
||||
|
||||
//Move values
|
||||
bi::vector<movable> v2
|
||||
bc::vector<movable> v2
|
||||
(boost::make_move_iterator(v.begin()), boost::make_move_iterator(v.end()));
|
||||
|
||||
//Test values have been moved
|
||||
|
Reference in New Issue
Block a user