Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template offset_ptr

boost::interprocess::offset_ptr

Synopsis

// In header: <boost/interprocess/offset_ptr.hpp>

template<typename PointedType, typename DifferenceType, typename OffsetType, 
          OffsetAlignment> 
class offset_ptr {
public:
  // types
  typedef                                                   ;     
  typedef                                                 ;          
  typedef                                                   ;        
  typedef                                                   ;       
  typedef                                                ;  
  typedef                               ;
  typedef                                                    ;      
  typedef offset_ptr<  ;           

  // public member functions
  () ;
  () ;
  template<typename T> () ;
  (offset_ptr &) ;
  template<typename T2> 
    (offset_ptr< ) ;
  template<typename T2, typename P2, typename O2,  A2> 
    (offset_ptr< , ) ;
  template<typename T2, typename P2, typename O2,  A2> 
    (offset_ptr< , ) ;
  template<typename T2, typename P2, typename O2,  A2> 
    (offset_ptr< , ) ;
  template<typename T2, typename P2, typename O2,  A2> 
    (offset_ptr< , ) ;
   () ;
   () ;
   () ;
   () ;
   () ;
  template<typename T> offset_ptr & () ;
  offset_ptr & (offset_ptr &) ;
  offset_ptr & () ;
  template<typename T2> 
    offset_ptr & 
    (offset_ptr< ) ;
  offset_ptr & () ;
  offset_ptr & () ;
  offset_ptr & () ;
  offset_ptr () ;
  offset_ptr & () ;
  offset_ptr () ;
  () ;
   () ;

  // public static functions
  offset_ptr () ;

  // friend functions
  offset_ptr (, offset_ptr) ;
  offset_ptr (offset_ptr, ) ;
  offset_ptr (offset_ptr, ) ;
  offset_ptr (, offset_ptr) ;
   (offset_ptr &, offset_ptr &) ;

  // private member functions
  template<typename T2> 
     (offset_ptr< , 
                ) ;
  template<typename T2> 
     (offset_ptr< , 
                ) ;
};

Description

A smart pointer that stores the offset between the pointer and the object it points to. This allows special properties, since the pointer is independent from the address of the pointee, if the pointer and the pointee are still separated by the same offset. This feature converts offset_ptr in a smart pointer that can be placed in shared memory and memory mapped files mapped at different addresses in every process.

b>Note: offset_ptr uses implementation defined properties, present in most platforms, for performance reasons:

  • Assumes that OffsetType representation of nullptr is (OffsetType)zero.

  • Assumes that incrementing a OffsetType obtained from a pointer is equivalent to incrementing the pointer and then converting it back to OffsetType.

Template Parameters

  1. typename PointedType

    The type of the pointee.

  2. typename DifferenceType

    A signed integer type that can represent the arithmetic operations on the pointer

  3. typename OffsetType

    An unsigned integer type that can represent the distance between two pointers reinterpret_cast-ed as unsigned integers. This type should be at least of the same size of std::uintptr_t. In some systems it's possible to communicate between 32 and 64 bit processes using 64 bit offsets.

  4.  OffsetAlignment

    Alignment of the OffsetType stored inside. In some systems might be necessary to align it to 64 bits in order to communicate 32 and 64 bit processes using 64 bit offsets.

offset_ptr public types

  1. typedef offset_ptr< ;

    Compatibility with pointer_traits

offset_ptr public member functions

  1. () ;

    Default constructor (null pointer). Never throws.

  2. () ;

    Constructor from nullptr. Never throws.

  3. template<typename T> ( ptr) ;

    Constructor from raw pointer. Only takes part in overload resolution if T* is convertible to PointedType* Never throws.

  4. (offset_ptr & ptr) ;

    Constructor from other offset_ptr. Never throws.

  5. template<typename T2> 
      (offset_ptr<  ptr) ;

    Constructor from other offset_ptr. Only takes part in overload resolution if T2* is convertible to PointedType*. Never throws.

  6. template<typename T2, typename P2, typename O2,  A2> 
      (offset_ptr<  r, ) ;

    Emulates static_cast operator. Never throws.

  7. template<typename T2, typename P2, typename O2,  A2> 
      (offset_ptr<  r, ) ;

    Emulates const_cast operator. Never throws.

  8. template<typename T2, typename P2, typename O2,  A2> 
      (offset_ptr<  r, ) ;

    Emulates dynamic_cast operator. Never throws.

  9. template<typename T2, typename P2, typename O2,  A2> 
      (offset_ptr<  r, ) ;

    Emulates reinterpret_cast operator. Never throws.

  10.  () ;

    Obtains raw pointer from offset. Never throws.

  11.  () ;
  12.  () ;

    Pointer-like -> operator. It can return 0 pointer. Never throws.

  13.  () ;

    Dereferencing operator, if it is a null offset_ptr behavior is undefined. Never throws.

  14.  ( idx) ;

    Indexing operator. Never throws.

  15. template<typename T> offset_ptr & ( ptr) ;

    Assignment from raw pointer. Only takes part in overload resolution if T* is convertible to PointedType* Never throws.

  16. offset_ptr & (offset_ptr & ptr) ;

    Assignment from other offset_ptr. Never throws.

  17. offset_ptr & () ;

    Assignment from nullptr. Never throws.

  18. template<typename T2> 
      offset_ptr & 
      (offset_ptr<  ptr) ;

    Assignment from related offset_ptr. Only takes part in overload resolution if T2* is convertible to PointedType* Never throws.

  19. offset_ptr & ( offset) ;

    offset_ptr += difference_type. Never throws.

  20. offset_ptr & ( offset) ;

    offset_ptr -= difference_type. Never throws.

  21. offset_ptr & () ;

    ++offset_ptr. Never throws.

  22. offset_ptr () ;

    offset_ptr++. Never throws.

  23. offset_ptr & () ;

    offset_ptr. Never throws.

  24. offset_ptr () ;

    offset_ptr–. Never throws.

  25. () ;

    safe bool conversion operator. Never throws.

  26.  () ;

    Not operator. Not needed in theory, but improves portability. Never throws

offset_ptr public static functions

  1. offset_ptr ( r) ;

    Compatibility with pointer_traits

offset_ptr friend functions

  1. offset_ptr ( diff, offset_ptr right) ;

    difference_type + offset_ptr operation

  2. offset_ptr (offset_ptr left,  diff) ;

    offset_ptr + difference_type operation

  3. offset_ptr (offset_ptr left,  diff) ;

    offset_ptr - diff operation

  4. offset_ptr ( diff, offset_ptr right) ;

    offset_ptr - diff operation

  5.  
    (offset_ptr & pt, offset_ptr & pt2) ;

    offset_ptr - offset_ptr operation

offset_ptr private member functions

  1. template<typename T2> 
       (offset_ptr<  ptr, 
                  ) ;
  2. template<typename T2> 
       (offset_ptr<  ptr, 
                  ) ;

PrevUpHomeNext