xentara-utils v2.0.4
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::ipc::ShmPointer< Type > Class Template Reference

A fancy pointer type suitable for use in shared memories. More...

#include <xentara/utils/ipc/ShmPointer.hpp>

Public Types

using element_type = Type
 The element type.
 
using difference_type = std::ptrdiff_t
 The type used to calculate offsets.
 
template<class OtherType >
using rebind = ShmPointer< OtherType >
 A type alias for a pointer to a different type;.
 

Public Member Functions

constexpr ShmPointer () noexcept=default
 Default constructor.
 
constexpr ShmPointer (Type *address) noexcept
 Conversion from an address stored in a regular pointer.
 
constexpr ShmPointer (std::nullptr_t) noexcept
 Constructor for a null pointer.
 
template<typename RelatedType >
requires std::convertible_to<RelatedType *, Type *>
constexpr ShmPointer (const ShmPointer< RelatedType > &pointer) noexcept
 Constructor for a pointer to a related type.
 
constexpr auto operator= (Type *rhs) noexcept -> ShmPointer &
 Assignment operator.
 
constexpr auto operator= (std::nullptr_t) noexcept -> ShmPointer &
 Assignment operator for a nullptr.
 
template<typename RelatedType >
requires std::convertible_to<RelatedType *, Type *>
auto operator= (const ShmPointer< RelatedType > &rhs) -> ShmPointer &
 Assignment operator for a related pointer.
 
constexpr auto operator== (const ShmPointer &) const -> bool
 Comparison operator.
 
constexpr auto operator<=> (const ShmPointer &rhs) const -> std::strong_ordering
 Three-Way-Comparison operator.
 
constexpr auto operator++ () noexcept -> ShmPointer &
 Pre-increment operator.
 
constexpr auto operator++ (int) noexcept -> ShmPointer
 Post-increment operator.
 
constexpr auto operator-- () noexcept -> ShmPointer &
 Pre-decrement operator.
 
constexpr auto operator-- (int) noexcept -> ShmPointer
 Post-decrement operator.
 
constexpr auto operator+= (difference_type offset) noexcept -> ShmPointer &
 Addition assignment operator.
 
constexpr auto operator-= (difference_type offset) noexcept -> ShmPointer &
 Subtraction assignment operator.
 
constexpr auto operator* () const noexcept -> Type &
 Indirection operator.
 
constexpr auto operator-> () const noexcept -> Type *
 Member access operator.
 
constexpr operator Type * () const noexcept
 Conversion to a native pointer.
 
constexpr auto operator[] (difference_type index) const noexcept -> Type &
 Subscript operator.
 

Detailed Description

template<typename Type>
class xentara::utils::ipc::ShmPointer< Type >

A fancy pointer type suitable for use in shared memories.

This is a pointer type that can safely be used in shared memories. When written to a shared memory, the pointer will always point to the same object in all mappings of the memory, even if they are at different addresses, as long as the pointed-to object lies in the same shared memory.

You can copy the pointer out of the shared memory in to regular private memory, but then it can no longer be shared between processes.

Template Parameters
TypeThe type the pointer points to

Member Typedef Documentation

◆ difference_type

template<typename Type >
using xentara::utils::ipc::ShmPointer< Type >::difference_type = std::ptrdiff_t

The type used to calculate offsets.

◆ element_type

template<typename Type >
using xentara::utils::ipc::ShmPointer< Type >::element_type = Type

The element type.

◆ rebind

template<typename Type >
template<class OtherType >
using xentara::utils::ipc::ShmPointer< Type >::rebind = ShmPointer<OtherType>

A type alias for a pointer to a different type;.

Constructor & Destructor Documentation

◆ ShmPointer() [1/4]

template<typename Type >
constexpr xentara::utils::ipc::ShmPointer< Type >::ShmPointer ( )
constexprdefaultnoexcept

Default constructor.

This constructor constructs an unititialized pointer

◆ ShmPointer() [2/4]

template<typename Type >
constexpr xentara::utils::ipc::ShmPointer< Type >::ShmPointer ( Type *  address)
constexprnoexcept

Conversion from an address stored in a regular pointer.

Parameters
addressThe address

◆ ShmPointer() [3/4]

template<typename Type >
constexpr xentara::utils::ipc::ShmPointer< Type >::ShmPointer ( std::nullptr_t  )
constexprnoexcept

Constructor for a null pointer.

◆ ShmPointer() [4/4]

template<typename Type >
template<typename RelatedType >
requires std::convertible_to<RelatedType *, Type *>
constexpr xentara::utils::ipc::ShmPointer< Type >::ShmPointer ( const ShmPointer< RelatedType > &  pointer)
constexprnoexcept

Constructor for a pointer to a related type.

Template Parameters
RelatedType
Parameters
pointer

Member Function Documentation

◆ operator Type *()

template<typename Type >
constexpr xentara::utils::ipc::ShmPointer< Type >::operator Type * ( ) const
constexprnoexcept

Conversion to a native pointer.

Note
Must not be called on a null pointer.

◆ operator*()

template<typename Type >
constexpr auto xentara::utils::ipc::ShmPointer< Type >::operator* ( ) const -> Type&
constexprnoexcept

Indirection operator.

Note
Must not be called on a null pointer.

◆ operator++() [1/2]

template<typename Type >
constexpr auto xentara::utils::ipc::ShmPointer< Type >::operator++ ( ) -> ShmPointer &
constexprnoexcept

Pre-increment operator.

Note
Must not be called on a null pointer.

◆ operator++() [2/2]

template<typename Type >
constexpr auto xentara::utils::ipc::ShmPointer< Type >::operator++ ( int  ) -> ShmPointer
constexprnoexcept

Post-increment operator.

Note
Must not be called on a null pointer.

◆ operator+=()

template<typename Type >
constexpr auto xentara::utils::ipc::ShmPointer< Type >::operator+= ( difference_type  offset) -> ShmPointer &
constexprnoexcept

Addition assignment operator.

Note
Must not be called on a null pointer.

◆ operator--() [1/2]

template<typename Type >
constexpr auto xentara::utils::ipc::ShmPointer< Type >::operator-- ( ) -> ShmPointer &
constexprnoexcept

Pre-decrement operator.

Note
Must not be called on a null pointer.

◆ operator--() [2/2]

template<typename Type >
constexpr auto xentara::utils::ipc::ShmPointer< Type >::operator-- ( int  ) -> ShmPointer
constexprnoexcept

Post-decrement operator.

Note
Must not be called on a null pointer.

◆ operator-=()

template<typename Type >
constexpr auto xentara::utils::ipc::ShmPointer< Type >::operator-= ( difference_type  offset) -> ShmPointer &
constexprnoexcept

Subtraction assignment operator.

Note
Must not be called on a null pointer.

◆ operator->()

template<typename Type >
constexpr auto xentara::utils::ipc::ShmPointer< Type >::operator-> ( ) const -> Type *
constexprnoexcept

Member access operator.

Note
Must not be called on a null pointer.

◆ operator<=>()

template<typename Type >
constexpr auto xentara::utils::ipc::ShmPointer< Type >::operator<=> ( const ShmPointer< Type > &  rhs) const -> std::strong_ordering
constexpr

Three-Way-Comparison operator.

◆ operator=() [1/3]

template<typename Type >
template<typename RelatedType >
requires std::convertible_to<RelatedType *, Type *>
auto xentara::utils::ipc::ShmPointer< Type >::operator= ( const ShmPointer< RelatedType > &  rhs) -> ShmPointer &

Assignment operator for a related pointer.

◆ operator=() [2/3]

template<typename Type >
constexpr auto xentara::utils::ipc::ShmPointer< Type >::operator= ( std::nullptr_t  ) -> ShmPointer &
constexprnoexcept

Assignment operator for a nullptr.

◆ operator=() [3/3]

template<typename Type >
constexpr auto xentara::utils::ipc::ShmPointer< Type >::operator= ( Type *  rhs) -> ShmPointer &
constexprnoexcept

Assignment operator.

◆ operator==()

template<typename Type >
constexpr auto xentara::utils::ipc::ShmPointer< Type >::operator== ( const ShmPointer< Type > &  ) const -> bool
constexpr

Comparison operator.

◆ operator[]()

template<typename Type >
constexpr auto xentara::utils::ipc::ShmPointer< Type >::operator[] ( difference_type  index) const -> Type&
constexprnoexcept

Subscript operator.

Note
Must not be called on a null pointer.