Ticket #1932: interprocess_movable.patch

File interprocess_movable.patch, 8.5 KB (added by Bryan Green <bryan.d.green@…>, 14 years ago)

patch

  • file_mapping.hpp

     
    5555   //!After the call, "moved" does not represent any shared memory object.
    5656   //!Does not throw
    5757   #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    58    file_mapping(detail::moved_object<file_mapping> &moved)
     58   file_mapping(const detail::moved_object<file_mapping> &moved)
    5959   {  this->swap(moved.get());   }
    6060   #else
    6161   file_mapping(file_mapping &&moved)
     
    6767   //!Does not throw
    6868   #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    6969   file_mapping &operator=
    70       (detail::moved_object<file_mapping> &moved)
     70      (const detail::moved_object<file_mapping> &moved)
    7171   { 
    7272      file_mapping tmp(moved);
    7373      this->swap(tmp);
     
    165165   }
    166166}
    167167
     168//!This class is movable
     169template <>
     170struct is_movable<file_mapping>
     171{
     172   enum {   value = true };
     173};
     174
    168175}  //namespace interprocess {
    169176}  //namespace boost {
    170177
  • windows_shared_memory.hpp

     
    8383   //!Does not throw
    8484   #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    8585   windows_shared_memory
    86       (detail::moved_object<windows_shared_memory> &moved)
     86      (const detail::moved_object<windows_shared_memory> &moved)
    8787   {  this->swap(moved.get());   }
    8888   #else
    8989   windows_shared_memory(windows_shared_memory &&moved)
     
    9595   //!Does not throw
    9696   #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    9797   windows_shared_memory &operator=
    98       (detail::moved_object<windows_shared_memory> &moved)
     98      (const detail::moved_object<windows_shared_memory> &moved)
    9999   { 
    100100      windows_shared_memory tmp(moved);
    101101      this->swap(tmp);
     
    235235   }
    236236}
    237237
     238//!This class is movable
     239template <>
     240struct is_movable<windows_shared_memory>
     241{
     242   enum {   value = true };
     243};
     244
    238245}  //namespace interprocess {
    239246}  //namespace boost {
    240247
  • mapped_region.hpp

     
    7979   //!Move constructor. *this will be constructed taking ownership of "other"'s
    8080   //!region and "other" will be left in default constructor state.
    8181   #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    82    mapped_region(detail::moved_object<mapped_region> other);
     82   mapped_region(const detail::moved_object<mapped_region> &other);
    8383   #else
    8484   mapped_region(mapped_region &&other);
    8585   #endif
     
    9191   //!Move assignment. If *this owns a memory mapped region, it will be
    9292   //!destroyed and it will take ownership of "other"'s memory mapped region.
    9393   #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    94    mapped_region &operator=(detail::moved_object<mapped_region> other);
     94   mapped_region &operator=(const detail::moved_object<mapped_region> &other);
    9595   #else
    9696   mapped_region &operator=(mapped_region &&other);
    9797   #endif
     
    151151{  x.swap(y);  }
    152152
    153153#ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    154 inline mapped_region &mapped_region::operator=(detail::moved_object<mapped_region> other)
     154inline mapped_region &mapped_region::operator=(const detail::moved_object<mapped_region> &other)
    155155{  this->swap(other.get());   return *this;  }
    156156#else
    157157inline mapped_region &mapped_region::operator=(mapped_region &&other)
     
    178178{}
    179179
    180180#ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    181 inline mapped_region::mapped_region(detail::moved_object<mapped_region> other)
     181inline mapped_region::mapped_region(const detail::moved_object<mapped_region> &other)
    182182   :  m_base(0), m_size(0), m_offset(0)
    183183   ,  m_extra_offset(0)
    184184   ,  m_file_mapping_hnd(detail::invalid_file())
     
    382382{}
    383383
    384384#ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    385 inline mapped_region::mapped_region(detail::moved_object<mapped_region> other)
     385inline mapped_region::mapped_region(const detail::moved_object<mapped_region> &other)
    386386   :  m_base(MAP_FAILED), m_size(0), m_offset(0),  m_extra_offset(0)
    387387{  this->swap(other.get());   }
    388388#else
     
    555555};
    556556/// @endcond
    557557
     558//!This class is movable
     559template <>
     560struct is_movable<mapped_region>
     561{
     562   enum {   value = true };
     563};
     564
    558565}  //namespace interprocess {
    559566}  //namespace boost {
    560567
  • managed_heap_memory.hpp

     
    7272   //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
    7373   #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    7474   basic_managed_heap_memory
    75       (detail::moved_object<basic_managed_heap_memory> &moved)
     75      (const detail::moved_object<basic_managed_heap_memory> &moved)
    7676   {  this->swap(moved.get());   }
    7777   #else
    7878   basic_managed_heap_memory(basic_managed_heap_memory &&moved)
     
    8282   //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
    8383   #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    8484   basic_managed_heap_memory &operator=
    85       (detail::moved_object<basic_managed_heap_memory> &moved)
     85      (const detail::moved_object<basic_managed_heap_memory> &moved)
    8686   {  this->swap(moved.get());   return *this;  }
    8787   #else
    8888   basic_managed_heap_memory &operator=
     
    139139   /// @endcond
    140140};
    141141
     142template
     143      <
     144         class CharType,
     145         class AllocationAlgorithm,
     146         template<class IndexConfig> class IndexType
     147      >
     148struct is_movable<basic_managed_heap_memory<CharType, AllocationAlgorithm,
     149                                            IndexType> >
     150{
     151   enum {   value = true };
     152};
     153
    142154}  //namespace interprocess {
    143155
    144156}  //namespace boost {
  • shared_memory_object.hpp

     
    7676   //!Does not throw
    7777   #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    7878   shared_memory_object
    79       (detail::moved_object<shared_memory_object> &moved)
     79      (const detail::moved_object<shared_memory_object> &moved)
    8080   {  this->swap(moved.get());   }
    8181   #else
    8282   shared_memory_object(shared_memory_object &&moved)
     
    8888   //!Does not throw
    8989   #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    9090   shared_memory_object &operator=
    91       (detail::moved_object<shared_memory_object> &moved)
     91      (const detail::moved_object<shared_memory_object> &moved)
    9292   { 
    9393      shared_memory_object tmp(moved);
    9494      this->swap(tmp);
     
    341341
    342342#endif
    343343
     344//!This class is movable
     345template <>
     346struct is_movable<shared_memory_object>
     347{
     348   enum {   value = true };
     349};
     350
    344351}  //namespace interprocess {
    345352}  //namespace boost {
    346353
  • managed_external_buffer.hpp

     
    4646   /// @endcond
    4747
    4848   public:
     49   //!Constructor. Allocates basic resources. Never throws.
     50   basic_managed_external_buffer() {}
     51
    4952   //!Creates and places the segment manager. This can throw
    5053   basic_managed_external_buffer
    5154      (create_only_t, void *addr, std::size_t size)
     
    7174   //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
    7275   #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    7376   basic_managed_external_buffer
    74       (detail::moved_object<basic_managed_external_buffer> &moved)
     77      (const detail::moved_object<basic_managed_external_buffer> &moved)
    7578   {  this->swap(moved.get());   }
    7679   #else
    7780   basic_managed_external_buffer
     
    8285   //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
    8386   #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    8487   basic_managed_external_buffer &operator=
    85       (detail::moved_object<basic_managed_external_buffer> &moved)
     88      (const detail::moved_object<basic_managed_external_buffer> &moved)
    8689   {  this->swap(moved.get());   return *this;  }
    8790   #else
    8891   basic_managed_external_buffer &operator=
     
    100103
    101104};
    102105
     106template
     107      <
     108         class CharType,
     109         class AllocationAlgorithm,
     110         template<class IndexConfig> class IndexType
     111      >
     112struct is_movable<basic_managed_external_buffer<CharType, AllocationAlgorithm,
     113                                                IndexType> >
     114{
     115   enum {   value = true };
     116};
     117
    103118}  //namespace interprocess {
    104119}  //namespace boost {
    105120