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

Lightweight read-only view over a const array stored in RODATA (will typically be in flash memory). More...

#include <helpers.h>

Public Types

using value_type = T
 

Public Member Functions

constexpr ConstVector ()=default
 
constexpr ConstVector (const T *data, size_t size)
 
const T * begin () const
 
const T * end () const
 
const T * data () const
 
constexpr size_t size () const
 
constexpr bool empty () const
 
const constexpr T & operator[] (size_t i) const
 
const T & at (size_t i) const
 

Protected Attributes

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

Detailed Description

template<typename T, bool Owning = false>
class esphome::ConstVector< T, Owning >

Lightweight read-only view over a const array stored in RODATA (will typically be in flash memory).

Iterators are raw pointers like FixedVector. With Owning = true it can also hold a heap copy it owns (see the specialization below); the default view never frees and has no extra cost.

Definition at line 130 of file helpers.h.

Member Typedef Documentation

◆ value_type

template<typename T , bool Owning = false>
using esphome::ConstVector< T, Owning >::value_type = T

Definition at line 132 of file helpers.h.

Constructor & Destructor Documentation

◆ ConstVector() [1/2]

template<typename T , bool Owning = false>
esphome::ConstVector< T, Owning >::ConstVector ( )
constexprdefault

◆ ConstVector() [2/2]

template<typename T , bool Owning = false>
esphome::ConstVector< T, Owning >::ConstVector ( const T * data,
size_t size )
inlineconstexpr

Definition at line 135 of file helpers.h.

Member Function Documentation

◆ at()

template<typename T , bool Owning = false>
const T & esphome::ConstVector< T, Owning >::at ( size_t i) const
inline

Definition at line 143 of file helpers.h.

◆ begin()

template<typename T , bool Owning = false>
const T * esphome::ConstVector< T, Owning >::begin ( ) const
inline

Definition at line 137 of file helpers.h.

◆ data()

template<typename T , bool Owning = false>
const T * esphome::ConstVector< T, Owning >::data ( ) const
inline

Definition at line 139 of file helpers.h.

◆ empty()

template<typename T , bool Owning = false>
bool esphome::ConstVector< T, Owning >::empty ( ) const
inlineconstexpr

Definition at line 141 of file helpers.h.

◆ end()

template<typename T , bool Owning = false>
const T * esphome::ConstVector< T, Owning >::end ( ) const
inline

Definition at line 138 of file helpers.h.

◆ operator[]()

template<typename T , bool Owning = false>
const constexpr T & esphome::ConstVector< T, Owning >::operator[] ( size_t i) const
inlineconstexpr

Definition at line 142 of file helpers.h.

◆ size()

template<typename T , bool Owning = false>
size_t esphome::ConstVector< T, Owning >::size ( ) const
inlineconstexpr

Definition at line 140 of file helpers.h.

Field Documentation

◆ data_

template<typename T , bool Owning = false>
const T* esphome::ConstVector< T, Owning >::data_ {nullptr}
protected

Definition at line 146 of file helpers.h.

◆ size_

template<typename T , bool Owning = false>
size_t esphome::ConstVector< T, Owning >::size_ {0}
protected

Definition at line 147 of file helpers.h.


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