Files
interprocess/test/movable_int.hpp
Ion Gaztañaga 48990c0766 Implemented N1780 proposal to LWG issue 233: Insertion hints in associative containers in interprocess boost::interprocess::multiset and boost::interprocess::multimap class.
Source breaking: A shared memory object is now used including shared_memory_object.hpp header instead of shared memory.hpp.
ABI breaking: Changed global mutex when initializing managed shared memory and memory mapped files. This change tries to minimize deadlocks.
Source breaking: Changed shared memory, memory mapped files and mapped region's open mode to a single boost::interprocess::mode_t type.
Added extra WIN32_LEAN_AND_MEAN before including DateTime headers to avoid socket redefinition errors when using Interprocess and Asio in windows.
ABI breaking: mapped_region constructor no longer requires classes derived from memory_mappable, but classes the fulfill the MemoryMappable concept.
Added in-place reallocation capabilities to basic_string.
ABI breaking: Reimplemented and optimized small string optimization. The narrow string class has zero byte overhead with an internal 11 byte buffer in 32 systems!
Added move semantics to containers. Experimental and not documented yet. Improves performance when using containers of containers.
ABI breaking: End nodes of node containers (list, slist, map/set) are now embedded in the containers instead of allocated using the allocator. This allows no-throw move-constructors and improves performance.
ABI breaking: slist and list containers now have constant-time size() function. The size of the container is added as a member.


[SVN r35618]
2006-10-15 14:07:15 +00:00

142 lines
3.6 KiB
C++

///////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztañaga 2006. 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_INTERPROCESS_TEST_MOVABLE_INT_HEADER
#define BOOST_INTERPROCESS_TEST_MOVABLE_INT_HEADER
#include <boost/interprocess/detail/config_begin.hpp>
#include <boost/interprocess/detail/workaround.hpp>
#include <boost/interprocess/detail/move.hpp>
namespace boost {
namespace interprocess {
namespace test {
class movable_int
{
movable_int(const movable_int&);
movable_int &operator= (const movable_int&);
public:
movable_int()
: m_int(0)
{}
explicit movable_int(int a)
: m_int(a)
{}
movable_int(const detail::moved_object<movable_int> &mmi)
: m_int(mmi.get().m_int)
{ mmi.get().m_int = 0; }
movable_int & operator= (const detail::moved_object<movable_int> &mmi)
{ this->m_int = mmi.get().m_int; mmi.get().m_int = 0; return *this; }
bool operator ==(const movable_int &mi) const
{ return this->m_int == mi.m_int; }
bool operator !=(const movable_int &mi) const
{ return this->m_int != mi.m_int; }
bool operator <(const movable_int &mi) const
{ return this->m_int < mi.m_int; }
bool operator <=(const movable_int &mi) const
{ return this->m_int <= mi.m_int; }
bool operator >=(const movable_int &mi) const
{ return this->m_int >= mi.m_int; }
bool operator >(const movable_int &mi) const
{ return this->m_int > mi.m_int; }
private:
int m_int;
};
class movable_and_copyable_int
{
public:
movable_and_copyable_int()
: m_int(0)
{}
explicit movable_and_copyable_int(int a)
: m_int(a)
{}
movable_and_copyable_int(const movable_and_copyable_int& mmi)
: m_int(mmi.m_int)
{}
movable_and_copyable_int &operator= (const movable_and_copyable_int& mi)
{ this->m_int = mi.m_int; return *this; }
movable_and_copyable_int(const detail::moved_object<movable_and_copyable_int> &mmi)
: m_int(mmi.get().m_int)
{ mmi.get().m_int = 0; }
movable_and_copyable_int & operator= (const detail::moved_object<movable_and_copyable_int> &mmi)
{ this->m_int = mmi.get().m_int; mmi.get().m_int = 0; return *this; }
bool operator ==(const movable_and_copyable_int &mi) const
{ return this->m_int == mi.m_int; }
bool operator !=(const movable_and_copyable_int &mi) const
{ return this->m_int != mi.m_int; }
bool operator <(const movable_and_copyable_int &mi) const
{ return this->m_int < mi.m_int; }
bool operator <=(const movable_and_copyable_int &mi) const
{ return this->m_int <= mi.m_int; }
bool operator >=(const movable_and_copyable_int &mi) const
{ return this->m_int >= mi.m_int; }
bool operator >(const movable_and_copyable_int &mi) const
{ return this->m_int > mi.m_int; }
private:
int m_int;
};
} //namespace test {
} //namespace interprocess {
} //namespace boost {
namespace boost{
namespace interprocess{
template<>
struct is_movable<test::movable_int>
{
public:
enum { value = true };
};
template<>
struct is_movable<test::movable_and_copyable_int>
{
public:
enum { value = true };
};
} //namespace interprocess{
} //namespace boost{
#include <boost/interprocess/detail/config_end.hpp>
#endif //#ifndef BOOST_INTERPROCESS_TEST_MOVABLE_INT_HEADER