ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
esphome::ConstVector< T, true > Class Template Reference

Owning variant: a codegen table that outlives it, or a heap copy of a runtime list it owns. More...

#include <helpers.h>

Public Types

using value_type = T
 

Public Member Functions

constexpr ConstVector ()=default
 
constexpr ConstVector (const T *data, size_t size)
 
 ConstVector (const ConstVector &)=delete
 
ConstVector & operator= (const ConstVector &)=delete
 
 ~ConstVector ()
 
const T * begin () const
 
const T * end () const
 
const T * data () const
 
size_t size () const
 
bool empty () const
 
const T & operator[] (size_t index) const
 
const T & at (size_t index) const
 
void assign_static (const T *data, size_t size)
 Codegen only: call before any runtime copy; it does not free a previous owned copy (generated setup() runs before any lambda or automation can call set_options).
 
void assign_copy (const T *data, size_t size)
 Copies the list into a heap array this owns, freeing a previous owned copy.
 

Protected Member Functions

void release_ ()
 

Protected Attributes

const T * data_ {nullptr}
 
size_t size_ {0}
 

Static Protected Attributes

static constexpr size_t OWNED_BIT = size_t{1} << (sizeof(size_t) * 8 - 1)
 

Detailed Description

template<typename T>
class esphome::ConstVector< T, true >

Owning variant: a codegen table that outlives it, or a heap copy of a runtime list it owns.

Ownership is the top bit of the size; it is not copyable, so a copy can never outlive the owner. Elements must be whole words so ESP8266 can read a codegen table from flash.

Definition at line 153 of file helpers.h.

Member Typedef Documentation

◆ value_type

template<typename T >
using esphome::ConstVector< T, true >::value_type = T

Definition at line 158 of file helpers.h.

Constructor & Destructor Documentation

◆ ConstVector() [1/3]

template<typename T >
esphome::ConstVector< T, true >::ConstVector ( )
constexprdefault

◆ ConstVector() [2/3]

template<typename T >
esphome::ConstVector< T, true >::ConstVector ( const T * data,
size_t size )
inlineconstexpr

Definition at line 161 of file helpers.h.

◆ ConstVector() [3/3]

template<typename T >
esphome::ConstVector< T, true >::ConstVector ( const ConstVector< T, true > & )
delete

◆ ~ConstVector()

template<typename T >
esphome::ConstVector< T, true >::~ConstVector ( )
inline

Definition at line 164 of file helpers.h.

Member Function Documentation

◆ assign_copy()

template<typename T >
void esphome::ConstVector< T, true >::assign_copy ( const T * data,
size_t size )
inline

Copies the list into a heap array this owns, freeing a previous owned copy.

Definition at line 181 of file helpers.h.

◆ assign_static()

template<typename T >
void esphome::ConstVector< T, true >::assign_static ( const T * data,
size_t size )
inline

Codegen only: call before any runtime copy; it does not free a previous owned copy (generated setup() runs before any lambda or automation can call set_options).

Definition at line 176 of file helpers.h.

◆ at()

template<typename T >
const T & esphome::ConstVector< T, true >::at ( size_t index) const
inline

Definition at line 172 of file helpers.h.

◆ begin()

template<typename T >
const T * esphome::ConstVector< T, true >::begin ( ) const
inline

Definition at line 166 of file helpers.h.

◆ data()

template<typename T >
const T * esphome::ConstVector< T, true >::data ( ) const
inline

Definition at line 168 of file helpers.h.

◆ empty()

template<typename T >
bool esphome::ConstVector< T, true >::empty ( ) const
inline

Definition at line 170 of file helpers.h.

◆ end()

template<typename T >
const T * esphome::ConstVector< T, true >::end ( ) const
inline

Definition at line 167 of file helpers.h.

◆ operator=()

template<typename T >
ConstVector & esphome::ConstVector< T, true >::operator= ( const ConstVector< T, true > & )
delete

◆ operator[]()

template<typename T >
const T & esphome::ConstVector< T, true >::operator[] ( size_t index) const
inline

Definition at line 171 of file helpers.h.

◆ release_()

template<typename T >
void esphome::ConstVector< T, true >::release_ ( )
inlineprotected

Definition at line 192 of file helpers.h.

◆ size()

template<typename T >
size_t esphome::ConstVector< T, true >::size ( ) const
inline

Definition at line 169 of file helpers.h.

Field Documentation

◆ data_

template<typename T >
const T* esphome::ConstVector< T, true >::data_ {nullptr}
protected

Definition at line 197 of file helpers.h.

◆ OWNED_BIT

template<typename T >
size_t esphome::ConstVector< T, true >::OWNED_BIT = size_t{1} << (sizeof(size_t) * 8 - 1)
staticconstexprprotected

Definition at line 190 of file helpers.h.

◆ size_

template<typename T >
size_t esphome::ConstVector< T, true >::size_ {0}
protected

Definition at line 198 of file helpers.h.


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