tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
small_ptr< Type, BaseAddress, StorageType > Struct Template Reference

Compressed pointer to specified size. Intended to be used as a drop in replacement for native pointers. More...

#include <small_ptr.hpp>

Public Member Functions

 small_ptr ()=default
 Default construct empty small_ptr. May contain garbage.
 
 small_ptr (nullptr_t null)
 Construct from nullptr.
 
 small_ptr (Type *ptr)
 Construct from raw pointer.
 
auto compressed_value () const noexcept -> StorageType
 Returns the compressed underlying integer address.
 
auto get () const noexcept -> Type const *
 Returns a raw pointer to const Type.
 
auto get () noexcept -> Type *
 Returns a raw pointer to Type.
 
 operator Type * () noexcept
 Implicit conversion to raw pointer to mutable.
 
 operator Type const * () const noexcept
 Implicit conversion to raw pointer to const.
 
auto operator* () -> Type &
 Dereference pointer to Type&.
 
auto operator* () const -> Type const &
 Dereference pointer to Type const&.
 
auto operator++ () noexcept -> small_ptr &
 Post increment of pointer.
 
auto operator++ (int) noexcept -> small_ptr
 Pre increment of pointer.
 
auto operator- (small_ptr other) const noexcept -> ptrdiff_t
 Returns distance from this to other.
 
auto operator-- () noexcept -> small_ptr &
 Post decrement of pointer.
 
auto operator-- (int) noexcept -> small_ptr
 Pre decrement of pointer.
 
auto operator-> () const -> Type *
 Returns a raw pointer to Type.
 

Detailed Description

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
struct etl::small_ptr< Type, BaseAddress, StorageType >

Compressed pointer to specified size. Intended to be used as a drop in replacement for native pointers.

Uses the base address to calculate an offset, which will be stored internally. If used on micro controllers, the base address should be set to the start of RAM. See your linker script.

Constructor & Destructor Documentation

◆ small_ptr() [1/3]

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
small_ptr ( )
default

Default construct empty small_ptr. May contain garbage.

◆ small_ptr() [2/3]

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
small_ptr ( nullptr_t null)
inline

Construct from nullptr.

◆ small_ptr() [3/3]

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
small_ptr ( Type * ptr)
inline

Construct from raw pointer.

Member Function Documentation

◆ compressed_value()

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
auto compressed_value ( ) const -> StorageType
inlinenodiscardnoexcept

Returns the compressed underlying integer address.

◆ get() [1/2]

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
auto get ( ) const -> Type const*
inlinenodiscardnoexcept

Returns a raw pointer to const Type.

◆ get() [2/2]

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
auto get ( ) -> Type*
inlinenodiscardnoexcept

Returns a raw pointer to Type.

◆ operator Type *()

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
operator Type * ( )
inlinenodiscardnoexcept

Implicit conversion to raw pointer to mutable.

◆ operator Type const *()

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
operator Type const * ( ) const
inlinenodiscardnoexcept

Implicit conversion to raw pointer to const.

◆ operator*() [1/2]

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
auto operator* ( ) -> Type&
inlinenodiscard

Dereference pointer to Type&.

◆ operator*() [2/2]

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
auto operator* ( ) const -> Type const&
inlinenodiscard

Dereference pointer to Type const&.

◆ operator++() [1/2]

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
auto operator++ ( ) -> small_ptr&
inlinenodiscardnoexcept

Post increment of pointer.

◆ operator++() [2/2]

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
auto operator++ ( int ) -> small_ptr
inlinenodiscardnoexcept

Pre increment of pointer.

◆ operator-()

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
auto operator- ( small_ptr< Type, BaseAddress, StorageType > other) const -> ptrdiff_t
inlinenodiscardnoexcept

Returns distance from this to other.

◆ operator--() [1/2]

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
auto operator-- ( ) -> small_ptr&
inlinenodiscardnoexcept

Post decrement of pointer.

◆ operator--() [2/2]

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
auto operator-- ( int ) -> small_ptr
inlinenodiscardnoexcept

Pre decrement of pointer.

◆ operator->()

template<typename Type, intptr_t BaseAddress = 0, typename StorageType = uint16_t>
auto operator-> ( ) const -> Type*
inlinenodiscard

Returns a raw pointer to Type.


The documentation for this struct was generated from the following file: