E.V.E
v2023.02.15
 
Loading...
Searching...
No Matches
eve::aligned_ptr< Type, Lanes > Struct Template Reference

Wrapper for non-owning aligned pointers. More...

#include <eve/memory/aligned_ptr.hpp>

Detailed Description

template<typename Type, typename Lanes = expected_cardinal_t<Type>>
struct eve::aligned_ptr< Type, Lanes >

Required header: #include <eve/memory/aligned_ptr.hpp>

aligned_ptr is a non-owning pointer that binds a preexisting aligned memory and prevent any alignment-altering operations to be performed. The bound pointer must be aligned so that it can be used to load at most Lanes element of type Type natively.

Rebinding to another pointer is allowed only if the new pointer's alignment is compatible with the current aligned_ptr constraints.

An aligned_ptr may alternatively own no object, in which case it is called empty.

Template Parameters
TypePointee type
LanesAlignment constraint to uphold. Default value is computed to be compatible with current SIMD ABI requirements.

Public Types

using value_type = std::remove_const_t< Type >
 The value type associated to the held pointer.
 
using pointer = std::add_pointer_t< Type >
 The NullablePointer type currently held.
 
template<typename T >
using rebind = aligned_ptr< T, Lanes >
 Generate an aligned_ptr with a different type but same Lanes
 

Public Member Functions

Constructors
 aligned_ptr () noexcept
 Default constructor.
 
 aligned_ptr (std::nullptr_t) noexcept
 Set the held pointer to nullptr
 
 aligned_ptr (pointer p) noexcept
 
template<typename UType , typename L >
 aligned_ptr (aligned_ptr< UType, L > p) noexcept
 Construct an aligned_ptr from another one with a compatible alignment constraint.
 
Assignment operators
template<typename L >
aligned_ptroperator= (aligned_ptr< Type, L > p) noexcept
 Assign from another aligned_ptr with a compatible alignment constraint.
 
Pointer arithmetic
aligned_ptroperator+= (std::ptrdiff_t o) noexcept
 Add an offset to the held pointer. Behavior is undefined if the offset forces the pointer to become misaligned.
 
aligned_ptroperator-= (std::ptrdiff_t o) noexcept
 Substract an offset to the held pointer. Behavior is undefined if the offset forces the pointer to become misaligned.
 
aligned_ptroperator++ () noexcept
 Pre-increments the held pointer. Does not participate in overload resolution if Lanes != 1
 
aligned_ptr operator++ (int) noexcept
 Post-increments the held pointer. Does not participate in overload resolution if Lanes != 1
 
aligned_ptroperator-- () noexcept
 Pre-decrements the held pointer. Does not participate in overload resolution if Lanes != 1
 
aligned_ptr operator-- (int) noexcept
 Post-decrements the held pointer. Does not participate in overload resolution if Lanes != 1
 
Other members
void swap (aligned_ptr &that) noexcept
 Exchanges the content of the aligned_ptr with those of that.
 
auto operator<=> (const aligned_ptr< Type, Lanes > &) const =default
 Compares aligned_ptr lexicographically.
 
Observers
 operator bool () const noexcept
 Checks if there is an associated held object.
 
 operator pointer () const noexcept
 Returns the pointer to the held object.
 
pointer get () const noexcept
 Returns the pointer to the held object.
 
decltype(auto) operator* () const noexcept
 Dereferences pointer to the held object.
 
decltype(auto) operator* () noexcept
 Dereferences pointer to the held object.
 
decltype(auto) operator-> () const noexcept
 Dereferences pointer to the held object.
 
decltype(auto) operator-> () noexcept
 Dereferences pointer to the held object.
 

Static Public Member Functions

static constexpr auto alignment () noexcept
 Return the value of the alignment constraint.
 

Related Functions

(Note that these are not member functions.)

template<typename Lanes , typename Type >
aligned_ptr< Type, Lanes > as_aligned (Type *ptr, Lanes lanes) noexcept
 Constructs an aligned_ptr from a pointer ptr. Behavior is undefined if ptr does not satisfy alignment constraint Lanes.
 
template<typename Type >
aligned_ptr< Type > as_aligned (Type *ptr) noexcept
 Constructs an aligned_ptr from a pointer ptr. Behavior is undefined if ptr does not satisfy the default alignment constraint.
 
template<typename T , typename Lanes >
auto previous_aligned_address (T *p, Lanes width) noexcept
 Computes an address lesser or equal to p which satisfies the alignment constraint of SIMD registers of size Lanes.
 
template<typename T >
auto previous_aligned_address (T *p) noexcept
 Computes an address lesser or equal to p which is satisfy the alignment constraint of current architecture's SIMD register.
 
template<typename T , typename Lanes >
auto next_aligned_address (T *p, Lanes width) noexcept
 Computes an address greater or equal to p which satisfies the alignment constraint of SIMD registers of size Lanes.
 
template<typename T >
auto next_aligned_address (T *p) noexcept
 Computes an address greater or equal to p which satisfies the alignment constraint of current architecture's SIMD register.