eve::aligned_ptr< Type, Lanes > Struct Template Reference
Wrapper for non-owning aligned pointers. More...
Detailed Description
template<typename Type, typename Lanes = expected_cardinal_t<Type>>
struct eve::aligned_ptr< Type, Lanes >
struct eve::aligned_ptr< Type, Lanes >
Wrapper for non-owning aligned pointers.
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 they 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
-
Type Pointee type Lanes Alignment 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 | |
Static Public Member Functions | |
static constexpr auto | alignment () noexcept |
Return the value of the alignment constraint. | |
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 L > | |
aligned_ptr (aligned_ptr< Type, L > p) noexcept | |
Construct an aligned_ptr from another one with a compatible alignment constraint. | |
Assignment operators | |
template<typename L > | |
aligned_ptr & | operator= (aligned_ptr< Type, L > p) noexcept |
Assign from another aligned_ptr with a compatible alignment constraint. | |
Pointer arithmetic | |
aligned_ptr & | operator+= (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_ptr & | operator-= (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_ptr & | operator++ () 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_ptr & | operator-- () 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. | |
Type const & | operator[] (std::size_t i) const noexcept |
Indexed array to the underlying array. | |
Type & | operator[] (std::size_t i) noexcept |
Indexed array to the underlying array. | |
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 . More... | |
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. More... | |
template<typename T , typename Lanes > | |
auto | previous_aligned_address (T *p, Lanes width) noexcept |
Computes an address lesser or equal to p which is satisfy the alignment constraint of SIMD registers of size Lanes . More... | |
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. More... | |