File indexing completed on 2025-01-18 09:38:35
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_INTERPROCESS_OFFSET_PTR_HPP
0012 #define BOOST_INTERPROCESS_OFFSET_PTR_HPP
0013
0014 #ifndef BOOST_CONFIG_HPP
0015 # include <boost/config.hpp>
0016 #endif
0017 #
0018 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 # pragma once
0020 #endif
0021
0022 #include <boost/interprocess/detail/config_begin.hpp>
0023 #include <boost/interprocess/detail/workaround.hpp>
0024
0025 #include <boost/type_traits/is_convertible.hpp>
0026 #include <boost/type_traits/is_constructible.hpp>
0027 #include <boost/type_traits/is_integral.hpp>
0028 #include <boost/type_traits/is_unsigned.hpp>
0029
0030 #include <boost/interprocess/interprocess_fwd.hpp>
0031 #include <boost/interprocess/detail/utilities.hpp>
0032 #include <boost/interprocess/detail/cast_tags.hpp>
0033 #include <boost/interprocess/detail/mpl.hpp>
0034 #include <boost/container/detail/type_traits.hpp> //alignment_of, aligned_storage
0035 #include <boost/assert.hpp>
0036 #include <boost/static_assert.hpp>
0037 #include <iosfwd>
0038
0039 #if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
0040 #pragma GCC diagnostic push
0041 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
0042 #endif
0043
0044
0045
0046
0047
0048
0049 namespace boost {
0050
0051 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0052
0053
0054 template <class T>
0055 struct has_trivial_destructor;
0056
0057 #endif
0058
0059 namespace interprocess {
0060
0061 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0062 namespace ipcdetail {
0063
0064 template<class OffsetType, std::size_t OffsetAlignment>
0065 union offset_ptr_internal
0066 {
0067 BOOST_STATIC_ASSERT(sizeof(OffsetType) >= sizeof(uintptr_t));
0068 BOOST_STATIC_ASSERT(boost::is_integral<OffsetType>::value && boost::is_unsigned<OffsetType>::value);
0069
0070 explicit offset_ptr_internal(OffsetType off)
0071 : m_offset(off)
0072 {}
0073
0074 OffsetType m_offset;
0075
0076 typename ::boost::container::dtl::aligned_storage
0077 < sizeof(OffsetType)
0078 , (OffsetAlignment == offset_type_alignment) ? 1u : OffsetAlignment
0079 >::type alignment_helper;
0080 };
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094 #define BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR
0095 template <class OffsetType>
0096 BOOST_INTERPROCESS_FORCEINLINE void * offset_ptr_to_raw_pointer(const volatile void *this_ptr, OffsetType offset)
0097 {
0098 typedef pointer_offset_caster<void*, OffsetType> caster_t;
0099 #ifndef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR
0100 if(offset == 1){
0101 return 0;
0102 }
0103 else{
0104 return caster_t(caster_t(this_ptr).offset() + offset).pointer();
0105 }
0106 #else
0107 OffsetType mask = offset == 1;
0108 --mask;
0109 OffsetType target_offset = caster_t(this_ptr).offset() + offset;
0110 target_offset &= mask;
0111 return caster_t(target_offset).pointer();
0112 #endif
0113 }
0114
0115
0116
0117
0118
0119
0120 #define BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF
0121 template<class OffsetType>
0122 BOOST_INTERPROCESS_FORCEINLINE OffsetType offset_ptr_to_offset(const volatile void *ptr, const volatile void *this_ptr)
0123 {
0124 typedef pointer_offset_caster<void*, OffsetType> caster_t;
0125 #ifndef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF
0126
0127 if(!ptr){
0128 return 1;
0129 }
0130 else{
0131 OffsetType offset = caster_t(ptr).offset()- caster_t(this_ptr).offset();
0132 BOOST_ASSERT(offset != 1);
0133 return offset;
0134 }
0135 #else
0136
0137
0138
0139
0140 OffsetType offset = caster_t(ptr).offset() - caster_t(this_ptr).offset();
0141 --offset;
0142 OffsetType mask = ptr == 0;
0143 --mask;
0144 offset &= mask;
0145 return ++offset;
0146 #endif
0147 }
0148
0149
0150
0151
0152
0153
0154 #define BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF_FROM_OTHER
0155 template<class OffsetType>
0156 BOOST_INTERPROCESS_FORCEINLINE OffsetType offset_ptr_to_offset_from_other
0157 (const volatile void *this_ptr, const volatile void *other_ptr, OffsetType other_offset)
0158 {
0159 typedef pointer_offset_caster<void*, OffsetType> caster_t;
0160 #ifndef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_OFF_FROM_OTHER
0161 if(other_offset == 1){
0162 return 1;
0163 }
0164 else{
0165 OffsetType offset = caster_t(other_ptr).offset() - caster_t(this_ptr).offset() + other_offset;
0166 BOOST_ASSERT(offset != 1);
0167 return offset;
0168 }
0169 #else
0170 OffsetType mask = other_offset == 1;
0171 --mask;
0172 OffsetType offset = caster_t(other_ptr).offset() - caster_t(this_ptr).offset();
0173 offset &= mask;
0174 return offset + other_offset;
0175
0176
0177
0178
0179
0180 #endif
0181 }
0182
0183
0184
0185
0186
0187
0188 template<class From, class To>
0189 struct offset_ptr_maintains_address
0190 {
0191 static const bool value = ipcdetail::is_cv_same<From, To>::value
0192 || ipcdetail::is_cv_same<void, To>::value
0193 || ipcdetail::is_cv_same<char, To>::value
0194 ;
0195 };
0196
0197 template<class From, class To, class Ret = void>
0198 struct enable_if_convertible_equal_address
0199 : enable_if_c< ::boost::is_convertible<From*, To*>::value
0200 && offset_ptr_maintains_address<From, To>::value
0201 , Ret>
0202 {};
0203
0204 template<class From, class To, class Ret = void>
0205 struct enable_if_convertible_unequal_address
0206 : enable_if_c< ::boost::is_convertible<From*, To*>::value
0207 && !offset_ptr_maintains_address<From, To>::value
0208 , Ret>
0209 {};
0210
0211 }
0212 #endif
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235 template <class PointedType, class DifferenceType, class OffsetType, std::size_t OffsetAlignment>
0236 class offset_ptr
0237 {
0238 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0239 typedef offset_ptr<PointedType, DifferenceType, OffsetType, OffsetAlignment> self_t;
0240 void unspecified_bool_type_func() const {}
0241 typedef void (self_t::*unspecified_bool_type)() const;
0242 #endif
0243
0244 public:
0245 typedef PointedType element_type;
0246 typedef PointedType * pointer;
0247 typedef typename ipcdetail::
0248 add_reference<PointedType>::type reference;
0249 typedef typename ipcdetail::
0250 remove_volatile<typename ipcdetail::
0251 remove_const<PointedType>::type
0252 >::type value_type;
0253 typedef DifferenceType difference_type;
0254 typedef std::random_access_iterator_tag iterator_category;
0255 typedef OffsetType offset_type;
0256
0257 public:
0258
0259
0260
0261 BOOST_INTERPROCESS_FORCEINLINE offset_ptr() BOOST_NOEXCEPT
0262 : internal(1)
0263 {}
0264
0265
0266
0267 BOOST_INTERPROCESS_FORCEINLINE offset_ptr(pointer ptr) BOOST_NOEXCEPT
0268 : internal(ipcdetail::offset_ptr_to_offset<OffsetType>(ptr, this))
0269 {}
0270
0271
0272
0273 template <class T>
0274 BOOST_INTERPROCESS_FORCEINLINE offset_ptr( T *ptr
0275 , typename ipcdetail::enable_if< ::boost::is_convertible<T*, PointedType*> >::type * = 0) BOOST_NOEXCEPT
0276 : internal(ipcdetail::offset_ptr_to_offset<OffsetType>(static_cast<PointedType*>(ptr), this))
0277 {}
0278
0279
0280
0281 BOOST_INTERPROCESS_FORCEINLINE offset_ptr(const offset_ptr& ptr) BOOST_NOEXCEPT
0282 : internal(ipcdetail::offset_ptr_to_offset_from_other(this, &ptr, ptr.internal.m_offset))
0283 {}
0284
0285
0286
0287 template<class T2>
0288 BOOST_INTERPROCESS_FORCEINLINE offset_ptr( const offset_ptr<T2, DifferenceType, OffsetType, OffsetAlignment> &ptr
0289 #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0290 , typename ipcdetail::enable_if_convertible_equal_address<T2, PointedType>::type* = 0
0291 #endif
0292 ) BOOST_NOEXCEPT
0293 : internal(ipcdetail::offset_ptr_to_offset_from_other(this, &ptr, ptr.get_offset()))
0294 {}
0295
0296 #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0297
0298 template<class T2>
0299 BOOST_INTERPROCESS_FORCEINLINE offset_ptr( const offset_ptr<T2, DifferenceType, OffsetType, OffsetAlignment> &ptr
0300 , typename ipcdetail::enable_if_convertible_unequal_address<T2, PointedType>::type* = 0) BOOST_NOEXCEPT
0301 : internal(ipcdetail::offset_ptr_to_offset<OffsetType>(static_cast<PointedType*>(ptr.get()), this))
0302 {}
0303
0304 #endif
0305
0306
0307
0308 template<class T2>
0309 BOOST_INTERPROCESS_FORCEINLINE explicit offset_ptr(const offset_ptr<T2, DifferenceType, OffsetType, OffsetAlignment> &ptr
0310 #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0311 , typename ipcdetail::enable_if_c<
0312 !::boost::is_convertible<T2*, PointedType*>::value && ::boost::is_constructible<T2*, PointedType*>::value
0313 >::type * = 0
0314 #endif
0315 ) BOOST_NOEXCEPT
0316 : internal(ipcdetail::offset_ptr_to_offset<OffsetType>(static_cast<PointedType*>(ptr.get()), this))
0317 {}
0318
0319
0320
0321 template<class T2, class P2, class O2, std::size_t A2>
0322 BOOST_INTERPROCESS_FORCEINLINE offset_ptr(const offset_ptr<T2, P2, O2, A2> & r, ipcdetail::static_cast_tag) BOOST_NOEXCEPT
0323 : internal(ipcdetail::offset_ptr_to_offset<OffsetType>(static_cast<PointedType*>(r.get()), this))
0324 {}
0325
0326
0327
0328 template<class T2, class P2, class O2, std::size_t A2>
0329 BOOST_INTERPROCESS_FORCEINLINE offset_ptr(const offset_ptr<T2, P2, O2, A2> & r, ipcdetail::const_cast_tag) BOOST_NOEXCEPT
0330 : internal(ipcdetail::offset_ptr_to_offset<OffsetType>(const_cast<PointedType*>(r.get()), this))
0331 {}
0332
0333
0334
0335 template<class T2, class P2, class O2, std::size_t A2>
0336 BOOST_INTERPROCESS_FORCEINLINE offset_ptr(const offset_ptr<T2, P2, O2, A2> & r, ipcdetail::dynamic_cast_tag) BOOST_NOEXCEPT
0337 : internal(ipcdetail::offset_ptr_to_offset<OffsetType>(dynamic_cast<PointedType*>(r.get()), this))
0338 {}
0339
0340
0341
0342 template<class T2, class P2, class O2, std::size_t A2>
0343 BOOST_INTERPROCESS_FORCEINLINE offset_ptr(const offset_ptr<T2, P2, O2, A2> & r, ipcdetail::reinterpret_cast_tag) BOOST_NOEXCEPT
0344 : internal(ipcdetail::offset_ptr_to_offset<OffsetType>(reinterpret_cast<PointedType*>(r.get()), this))
0345 {}
0346
0347
0348
0349 BOOST_INTERPROCESS_FORCEINLINE pointer get() const BOOST_NOEXCEPT
0350 { return static_cast<pointer>(ipcdetail::offset_ptr_to_raw_pointer(this, this->internal.m_offset)); }
0351
0352 BOOST_INTERPROCESS_FORCEINLINE offset_type get_offset() const BOOST_NOEXCEPT
0353 { return this->internal.m_offset; }
0354
0355
0356
0357 BOOST_INTERPROCESS_FORCEINLINE pointer operator->() const BOOST_NOEXCEPT
0358 { return this->get(); }
0359
0360
0361
0362 BOOST_INTERPROCESS_FORCEINLINE reference operator* () const BOOST_NOEXCEPT
0363 {
0364 pointer p = this->get();
0365 reference r = *p;
0366 return r;
0367 }
0368
0369
0370
0371 BOOST_INTERPROCESS_FORCEINLINE reference operator[](difference_type idx) const BOOST_NOEXCEPT
0372 { return this->get()[idx]; }
0373
0374
0375
0376 BOOST_INTERPROCESS_FORCEINLINE offset_ptr& operator= (pointer from) BOOST_NOEXCEPT
0377 {
0378 this->internal.m_offset = ipcdetail::offset_ptr_to_offset<OffsetType>(from, this);
0379 return *this;
0380 }
0381
0382
0383
0384 BOOST_INTERPROCESS_FORCEINLINE offset_ptr& operator= (const offset_ptr & ptr) BOOST_NOEXCEPT
0385 {
0386 this->internal.m_offset = ipcdetail::offset_ptr_to_offset_from_other(this, &ptr, ptr.internal.m_offset);
0387 return *this;
0388 }
0389
0390
0391
0392 template<class T2> BOOST_INTERPROCESS_FORCEINLINE
0393 #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0394 typename ipcdetail::enable_if_c
0395 < ::boost::is_convertible<T2*, PointedType*>::value, offset_ptr&>::type
0396 #else
0397 offset_ptr&
0398 #endif
0399 operator= (const offset_ptr<T2, DifferenceType, OffsetType, OffsetAlignment> &ptr) BOOST_NOEXCEPT
0400 {
0401 this->assign(ptr, ipcdetail::bool_<ipcdetail::offset_ptr_maintains_address<T2, PointedType>::value>());
0402 return *this;
0403 }
0404
0405 public:
0406
0407
0408
0409 BOOST_INTERPROCESS_FORCEINLINE offset_ptr &operator+= (difference_type offset) BOOST_NOEXCEPT
0410 { this->inc_offset(offset * difference_type(sizeof(PointedType))); return *this; }
0411
0412
0413
0414 BOOST_INTERPROCESS_FORCEINLINE offset_ptr &operator-= (difference_type offset) BOOST_NOEXCEPT
0415 { this->dec_offset(offset * difference_type(sizeof(PointedType))); return *this; }
0416
0417
0418
0419 BOOST_INTERPROCESS_FORCEINLINE offset_ptr& operator++ (void) BOOST_NOEXCEPT
0420 { this->inc_offset(difference_type(sizeof(PointedType))); return *this; }
0421
0422
0423
0424 BOOST_INTERPROCESS_FORCEINLINE offset_ptr operator++ (int) BOOST_NOEXCEPT
0425 {
0426 offset_ptr tmp(*this);
0427 this->inc_offset(sizeof (PointedType));
0428 return tmp;
0429 }
0430
0431
0432
0433 BOOST_INTERPROCESS_FORCEINLINE offset_ptr& operator-- (void) BOOST_NOEXCEPT
0434 { this->dec_offset(sizeof (PointedType)); return *this; }
0435
0436
0437
0438 BOOST_INTERPROCESS_FORCEINLINE offset_ptr operator-- (int) BOOST_NOEXCEPT
0439 {
0440 offset_ptr tmp(*this);
0441 this->dec_offset(sizeof (PointedType));
0442 return tmp;
0443 }
0444
0445
0446
0447 #if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
0448 BOOST_INTERPROCESS_FORCEINLINE operator unspecified_bool_type() const BOOST_NOEXCEPT
0449 { return this->internal.m_offset != 1? &self_t::unspecified_bool_type_func : 0; }
0450 #else
0451 explicit operator bool() const BOOST_NOEXCEPT
0452 { return this->internal.m_offset != 1; }
0453 #endif
0454
0455
0456
0457 BOOST_INTERPROCESS_FORCEINLINE bool operator! () const BOOST_NOEXCEPT
0458 { return this->internal.m_offset == 1; }
0459
0460
0461
0462 #if defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
0463 template <class U>
0464 struct rebind
0465 { typedef offset_ptr<U, DifferenceType, OffsetType, OffsetAlignment> other; };
0466 #else
0467 template <class U>
0468 using rebind = offset_ptr<U, DifferenceType, OffsetType, OffsetAlignment>;
0469 #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0470 typedef offset_ptr<PointedType, DifferenceType, OffsetType, OffsetAlignment> other;
0471 #endif
0472 #endif
0473
0474
0475
0476 BOOST_INTERPROCESS_FORCEINLINE static offset_ptr pointer_to(reference r) BOOST_NOEXCEPT
0477 { return offset_ptr(&r); }
0478
0479
0480
0481 BOOST_INTERPROCESS_FORCEINLINE friend offset_ptr operator+(difference_type diff, offset_ptr right) BOOST_NOEXCEPT
0482 { right += diff; return right; }
0483
0484
0485
0486 BOOST_INTERPROCESS_FORCEINLINE friend offset_ptr operator+(offset_ptr left, difference_type diff) BOOST_NOEXCEPT
0487 { left += diff; return left; }
0488
0489
0490
0491 BOOST_INTERPROCESS_FORCEINLINE friend offset_ptr operator-(offset_ptr left, difference_type diff) BOOST_NOEXCEPT
0492 { left -= diff; return left; }
0493
0494
0495
0496 BOOST_INTERPROCESS_FORCEINLINE friend offset_ptr operator-(difference_type diff, offset_ptr right) BOOST_NOEXCEPT
0497 { right -= diff; return right; }
0498
0499
0500
0501 BOOST_INTERPROCESS_FORCEINLINE friend difference_type operator-(const offset_ptr &pt, const offset_ptr &pt2) BOOST_NOEXCEPT
0502 { return difference_type(pt.get()- pt2.get()); }
0503
0504
0505 BOOST_INTERPROCESS_FORCEINLINE friend bool operator== (const offset_ptr &pt1, const offset_ptr &pt2) BOOST_NOEXCEPT
0506 { return pt1.get() == pt2.get(); }
0507
0508 BOOST_INTERPROCESS_FORCEINLINE friend bool operator!= (const offset_ptr &pt1, const offset_ptr &pt2) BOOST_NOEXCEPT
0509 { return pt1.get() != pt2.get(); }
0510
0511 BOOST_INTERPROCESS_FORCEINLINE friend bool operator<(const offset_ptr &pt1, const offset_ptr &pt2) BOOST_NOEXCEPT
0512 { return pt1.get() < pt2.get(); }
0513
0514 BOOST_INTERPROCESS_FORCEINLINE friend bool operator<=(const offset_ptr &pt1, const offset_ptr &pt2) BOOST_NOEXCEPT
0515 { return pt1.get() <= pt2.get(); }
0516
0517 BOOST_INTERPROCESS_FORCEINLINE friend bool operator>(const offset_ptr &pt1, const offset_ptr &pt2) BOOST_NOEXCEPT
0518 { return pt1.get() > pt2.get(); }
0519
0520 BOOST_INTERPROCESS_FORCEINLINE friend bool operator>=(const offset_ptr &pt1, const offset_ptr &pt2) BOOST_NOEXCEPT
0521 { return pt1.get() >= pt2.get(); }
0522
0523
0524 BOOST_INTERPROCESS_FORCEINLINE friend bool operator== (pointer pt1, const offset_ptr &pt2) BOOST_NOEXCEPT
0525 { return pt1 == pt2.get(); }
0526
0527 BOOST_INTERPROCESS_FORCEINLINE friend bool operator!= (pointer pt1, const offset_ptr &pt2) BOOST_NOEXCEPT
0528 { return pt1 != pt2.get(); }
0529
0530 BOOST_INTERPROCESS_FORCEINLINE friend bool operator<(pointer pt1, const offset_ptr &pt2) BOOST_NOEXCEPT
0531 { return pt1 < pt2.get(); }
0532
0533 BOOST_INTERPROCESS_FORCEINLINE friend bool operator<=(pointer pt1, const offset_ptr &pt2) BOOST_NOEXCEPT
0534 { return pt1 <= pt2.get(); }
0535
0536 BOOST_INTERPROCESS_FORCEINLINE friend bool operator>(pointer pt1, const offset_ptr &pt2) BOOST_NOEXCEPT
0537 { return pt1 > pt2.get(); }
0538
0539 BOOST_INTERPROCESS_FORCEINLINE friend bool operator>=(pointer pt1, const offset_ptr &pt2) BOOST_NOEXCEPT
0540 { return pt1 >= pt2.get(); }
0541
0542
0543 BOOST_INTERPROCESS_FORCEINLINE friend bool operator== (const offset_ptr &pt1, pointer pt2) BOOST_NOEXCEPT
0544 { return pt1.get() == pt2; }
0545
0546 BOOST_INTERPROCESS_FORCEINLINE friend bool operator!= (const offset_ptr &pt1, pointer pt2) BOOST_NOEXCEPT
0547 { return pt1.get() != pt2; }
0548
0549 BOOST_INTERPROCESS_FORCEINLINE friend bool operator<(const offset_ptr &pt1, pointer pt2) BOOST_NOEXCEPT
0550 { return pt1.get() < pt2; }
0551
0552 BOOST_INTERPROCESS_FORCEINLINE friend bool operator<=(const offset_ptr &pt1, pointer pt2) BOOST_NOEXCEPT
0553 { return pt1.get() <= pt2; }
0554
0555 BOOST_INTERPROCESS_FORCEINLINE friend bool operator>(const offset_ptr &pt1, pointer pt2) BOOST_NOEXCEPT
0556 { return pt1.get() > pt2; }
0557
0558 BOOST_INTERPROCESS_FORCEINLINE friend bool operator>=(const offset_ptr &pt1, pointer pt2) BOOST_NOEXCEPT
0559 { return pt1.get() >= pt2; }
0560
0561 BOOST_INTERPROCESS_FORCEINLINE friend void swap(offset_ptr &left, offset_ptr &right) BOOST_NOEXCEPT
0562 {
0563 pointer ptr = right.get();
0564 right = left;
0565 left = ptr;
0566 }
0567
0568 private:
0569 template<class T2>
0570 BOOST_INTERPROCESS_FORCEINLINE void assign(const offset_ptr<T2, DifferenceType, OffsetType, OffsetAlignment> &ptr, ipcdetail::bool_<true>) BOOST_NOEXCEPT
0571 {
0572 this->internal.m_offset = ipcdetail::offset_ptr_to_offset_from_other<OffsetType>(this, &ptr, ptr.get_offset());
0573 }
0574
0575 template<class T2>
0576 BOOST_INTERPROCESS_FORCEINLINE void assign(const offset_ptr<T2, DifferenceType, OffsetType, OffsetAlignment> &ptr, ipcdetail::bool_<false>) BOOST_NOEXCEPT
0577 {
0578 this->internal.m_offset = ipcdetail::offset_ptr_to_offset<OffsetType>(static_cast<PointedType*>(ptr.get()), this);
0579 }
0580
0581 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0582 BOOST_INTERPROCESS_FORCEINLINE void inc_offset(DifferenceType bytes) BOOST_NOEXCEPT
0583 { internal.m_offset += OffsetType(bytes); }
0584
0585 BOOST_INTERPROCESS_FORCEINLINE void dec_offset(DifferenceType bytes) BOOST_NOEXCEPT
0586 { internal.m_offset -= OffsetType(bytes); }
0587
0588 ipcdetail::offset_ptr_internal<OffsetType, OffsetAlignment> internal;
0589
0590 public:
0591 BOOST_INTERPROCESS_FORCEINLINE const OffsetType &priv_offset() const BOOST_NOEXCEPT
0592 { return internal.m_offset; }
0593
0594 BOOST_INTERPROCESS_FORCEINLINE OffsetType &priv_offset() BOOST_NOEXCEPT
0595 { return internal.m_offset; }
0596
0597 #endif
0598 };
0599
0600
0601
0602 template<class E, class T, class W, class X, class Y, std::size_t Z>
0603 inline std::basic_ostream<E, T> & operator<<
0604 (std::basic_ostream<E, T> & os, offset_ptr<W, X, Y, Z> const & p)
0605 { return os << p.get_offset(); }
0606
0607
0608
0609 template<class E, class T, class W, class X, class Y, std::size_t Z>
0610 inline std::basic_istream<E, T> & operator>>
0611 (std::basic_istream<E, T> & is, offset_ptr<W, X, Y, Z> & p)
0612 { return is >> p.get_offset(); }
0613
0614
0615 template<class T1, class P1, class O1, std::size_t A1, class T2, class P2, class O2, std::size_t A2>
0616 BOOST_INTERPROCESS_FORCEINLINE boost::interprocess::offset_ptr<T1, P1, O1, A1>
0617 static_pointer_cast(const boost::interprocess::offset_ptr<T2, P2, O2, A2> & r) BOOST_NOEXCEPT
0618 {
0619 return boost::interprocess::offset_ptr<T1, P1, O1, A1>
0620 (r, boost::interprocess::ipcdetail::static_cast_tag());
0621 }
0622
0623
0624 template<class T1, class P1, class O1, std::size_t A1, class T2, class P2, class O2, std::size_t A2>
0625 BOOST_INTERPROCESS_FORCEINLINE boost::interprocess::offset_ptr<T1, P1, O1, A1>
0626 const_pointer_cast(const boost::interprocess::offset_ptr<T2, P2, O2, A2> & r) BOOST_NOEXCEPT
0627 {
0628 return boost::interprocess::offset_ptr<T1, P1, O1, A1>
0629 (r, boost::interprocess::ipcdetail::const_cast_tag());
0630 }
0631
0632
0633 template<class T1, class P1, class O1, std::size_t A1, class T2, class P2, class O2, std::size_t A2>
0634 BOOST_INTERPROCESS_FORCEINLINE boost::interprocess::offset_ptr<T1, P1, O1, A1>
0635 dynamic_pointer_cast(const boost::interprocess::offset_ptr<T2, P2, O2, A2> & r) BOOST_NOEXCEPT
0636 {
0637 return boost::interprocess::offset_ptr<T1, P1, O1, A1>
0638 (r, boost::interprocess::ipcdetail::dynamic_cast_tag());
0639 }
0640
0641
0642 template<class T1, class P1, class O1, std::size_t A1, class T2, class P2, class O2, std::size_t A2>
0643 BOOST_INTERPROCESS_FORCEINLINE boost::interprocess::offset_ptr<T1, P1, O1, A1>
0644 reinterpret_pointer_cast(const boost::interprocess::offset_ptr<T2, P2, O2, A2> & r) BOOST_NOEXCEPT
0645 {
0646 return boost::interprocess::offset_ptr<T1, P1, O1, A1>
0647 (r, boost::interprocess::ipcdetail::reinterpret_cast_tag());
0648 }
0649
0650 }
0651
0652 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0653
0654
0655 template <class T, class P, class O, std::size_t A>
0656 struct has_trivial_destructor< ::boost::interprocess::offset_ptr<T, P, O, A> >
0657 {
0658 static const bool value = true;
0659 };
0660
0661 namespace move_detail {
0662
0663
0664 template <class T, class P, class O, std::size_t A>
0665 struct is_trivially_destructible< ::boost::interprocess::offset_ptr<T, P, O, A> >
0666 {
0667 static const bool value = true;
0668 };
0669
0670 }
0671
0672 namespace interprocess {
0673
0674
0675
0676 template <class T, class P, class O, std::size_t A>
0677 BOOST_INTERPROCESS_FORCEINLINE T * to_raw_pointer(boost::interprocess::offset_ptr<T, P, O, A> const & p) BOOST_NOEXCEPT
0678 { return ipcdetail::to_raw_pointer(p); }
0679
0680 }
0681
0682
0683 #endif
0684 }
0685
0686 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0687
0688 namespace boost{
0689
0690
0691
0692 namespace intrusive {
0693
0694
0695 template<class VoidPointer, std::size_t N>
0696 struct max_pointer_plus_bits;
0697
0698 template<std::size_t OffsetAlignment, class P, class O, std::size_t A>
0699 struct max_pointer_plus_bits<boost::interprocess::offset_ptr<void, P, O, A>, OffsetAlignment>
0700 {
0701
0702
0703 static const std::size_t value = ::boost::interprocess::ipcdetail::ls_zeros<OffsetAlignment>::value - 1;
0704 };
0705
0706
0707 template<class Pointer, std::size_t NumBits>
0708 struct pointer_plus_bits;
0709
0710 template<class T, class P, class O, std::size_t A, std::size_t NumBits>
0711 struct pointer_plus_bits<boost::interprocess::offset_ptr<T, P, O, A>, NumBits>
0712 {
0713 typedef boost::interprocess::offset_ptr<T, P, O, A> pointer;
0714
0715
0716 static const O Mask = ((static_cast<O>(1) << NumBits) - static_cast<O>(1)) << 1;
0717 BOOST_STATIC_ASSERT(0 ==(Mask&1));
0718
0719
0720
0721
0722 BOOST_INTERPROCESS_FORCEINLINE static pointer get_pointer(const pointer &n) BOOST_NOEXCEPT
0723 {
0724 pointer p;
0725 O const tmp_off = n.priv_offset() & ~Mask;
0726 p.priv_offset() = boost::interprocess::ipcdetail::offset_ptr_to_offset_from_other(&p, &n, tmp_off);
0727 return p;
0728 }
0729
0730 BOOST_INTERPROCESS_FORCEINLINE static void set_pointer(pointer &n, const pointer &p) BOOST_NOEXCEPT
0731 {
0732 BOOST_ASSERT(0 == (get_bits)(p));
0733 O const stored_bits = n.priv_offset() & Mask;
0734 n = p;
0735 n.priv_offset() |= stored_bits;
0736 }
0737
0738 BOOST_INTERPROCESS_FORCEINLINE static std::size_t get_bits(const pointer &n) BOOST_NOEXCEPT
0739 {
0740 return std::size_t((n.priv_offset() & Mask) >> 1u);
0741 }
0742
0743 BOOST_INTERPROCESS_FORCEINLINE static void set_bits(pointer &n, std::size_t const b) BOOST_NOEXCEPT
0744 {
0745 BOOST_ASSERT(b < (std::size_t(1) << NumBits));
0746 O tmp = n.priv_offset();
0747 tmp &= ~Mask;
0748 tmp |= O(b << 1u);
0749 n.priv_offset() = tmp;
0750 }
0751 };
0752
0753 }
0754
0755
0756 template<class T, class U>
0757 struct pointer_to_other;
0758
0759
0760 template <class PointedType, class DifferenceType, class OffsetType, std::size_t OffsetAlignment, class U>
0761 struct pointer_to_other
0762 < ::boost::interprocess::offset_ptr<PointedType, DifferenceType, OffsetType, OffsetAlignment>, U >
0763 {
0764 typedef ::boost::interprocess::offset_ptr<U, DifferenceType, OffsetType, OffsetAlignment> type;
0765 };
0766
0767 }
0768 #endif
0769
0770 #include <boost/interprocess/detail/config_end.hpp>
0771
0772 #if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
0773 #pragma GCC diagnostic pop
0774 #endif
0775
0776 #endif