-
#include "tensorstore/util/byte_strided_pointer.h"
-
template <typename T>
class tensorstore::ByteStridedPointer; Wrapper type for a raw pointer for which pointer arithmetic operates with a stride of 1 byte, rather than a stride of
sizeof(T)
bytes.If the run-time type of the pointee is
U
, all byte offsets used for arithmetic MUST be a multiple ofalignof(U)
.- Template Parameters:¶
- typename T¶
The (possibly const-qualified) type of the pointee. It may be
void
orconst void
to indicate that the type is not known at compile time.
Types¶
- using element_type = T;
Pointee type.
- using difference_type = ptrdiff_t;
Pointer difference type, in bytes.
Data members¶
Constructors¶
- ByteStridedPointer();
Default initialization, leaves the wrapped raw pointer in an uninitialized state.
- ByteStridedPointer(U* value);
- explicit ByteStridedPointer(U* value);
Constructs from a compatible raw pointer.
- ByteStridedPointer(ByteStridedPointer<U> value);
- explicit ByteStridedPointer(ByteStridedPointer<U> value);
Converts from a compatible
ByteStridedPointer
type.
Accessors¶
- T* operator->() const;
Enables member access to the pointee.
- operator T*() const;
- explicit operator U*() const;
Converts to a raw pointer.
Arithmetic operations¶
- ByteStridedPointer& operator+=(Integer byte_offset);
Increments the raw pointer by
byte_offset
bytes.
- ByteStridedPointer& operator-=(Integer byte_offset);
Decrements the raw pointer by
byte_offset
bytes.
- T& operator[](Integer byte_offset) const;
Returns a reference to the element starting at the specified
byte_offset
relative toget()
.
-
friend ptrdiff_t
operator-(ByteStridedPointer<T> a, ByteStridedPointer<U> b); Computes the byte offset between two pointers.
-
friend ByteStridedPointer<T>
operator+(ByteStridedPointer<T> ptr, Integer byte_offset); -
friend ByteStridedPointer<T>
operator+(Integer byte_offset, ByteStridedPointer<T> ptr); Adds a byte offset to a pointer.
-
friend ByteStridedPointer<T>
operator-(ByteStridedPointer<T> ptr, Integer byte_offset); Subtracts a byte offset from a pointer.