ESPHome 2026.5.0-dev
Loading...
Searching...
No Matches
esphome::TemplatableValue< T, X > Class Template Reference

Primary TemplatableValue: stores either a constant value or a function pointer. More...

#include <automation.h>

Data Structures

union  Storage
 

Public Member Functions

 TemplatableValue ()=default
 
 TemplatableValue (std::nullptr_t)=delete
 
template<typename V >
requires (!std::invocable<V, X...>)
 TemplatableValue (V value)
 
template<typename F >
requires std::convertible_to<F, T (*)(X...)>
 TemplatableValue (F f)
 
template<typename F >
requires (!std::convertible_to<F, T (*)(X...)>) && std::invocable<F, X...> &&std::convertible_to<std::invoke_result_t<F, X...>, T> &&std::is_empty_v<F> &&std::default_initializable<F>
 TemplatableValue (F)
 
template<typename F >
requires std::invocable<F, X...> && (!std::convertible_to<F, T (*)(X...)>) &&(!std::is_empty_v<F> || !std::convertible_to<std::invoke_result_t<F, X...>, T> || !std::default_initializable<F>)
 TemplatableValue (F)=delete
 
 TemplatableValue (const TemplatableValue &other)
 
 TemplatableValue (TemplatableValue &&other) noexcept
 
TemplatableValueoperator= (const TemplatableValue &other)
 
TemplatableValueoperator= (TemplatableValue &&other) noexcept
 
 ~TemplatableValue ()
 
bool has_value () const
 
value (X... x) const
 
optional< T > optional_value (X... x) const
 
value_or (X... x, T default_value) const
 

Protected Types

enum  Tag : uint8_t { NONE , VALUE , FN }
 

Protected Member Functions

void destroy_ ()
 

Protected Attributes

enum esphome::TemplatableValue::Tag NONE
 
union esphome::TemplatableValue::Storage storage_
 

Detailed Description

template<typename T, typename... X>
class esphome::TemplatableValue< T, X >

Primary TemplatableValue: stores either a constant value or a function pointer.

No std::function, no string-specific paths. 8 bytes on 32-bit. Accepts raw constants for backward compatibility with direct C++ usage.

Definition at line 115 of file automation.h.

Member Enumeration Documentation

◆ Tag

template<typename T , typename... X>
enum esphome::TemplatableValue::Tag : uint8_t
protected
Enumerator
NONE 
VALUE 
FN 

Definition at line 224 of file automation.h.

Constructor & Destructor Documentation

◆ TemplatableValue() [1/8]

template<typename T , typename... X>
esphome::TemplatableValue< T, X >::TemplatableValue ( )
default

◆ TemplatableValue() [2/8]

template<typename T , typename... X>
esphome::TemplatableValue< T, X >::TemplatableValue ( std::nullptr_t )
delete

◆ TemplatableValue() [3/8]

template<typename T , typename... X>
template<typename V >
requires (!std::invocable<V, X...>)
esphome::TemplatableValue< T, X >::TemplatableValue ( V value)
inline

Definition at line 121 of file automation.h.

◆ TemplatableValue() [4/8]

template<typename T , typename... X>
template<typename F >
requires std::convertible_to<F, T (*)(X...)>
esphome::TemplatableValue< T, X >::TemplatableValue ( F f)
inline

Definition at line 126 of file automation.h.

◆ TemplatableValue() [5/8]

template<typename T , typename... X>
template<typename F >
requires (!std::convertible_to<F, T (*)(X...)>) && std::invocable<F, X...> &&std::convertible_to<std::invoke_result_t<F, X...>, T> &&std::is_empty_v<F> &&std::default_initializable<F>
esphome::TemplatableValue< T, X >::TemplatableValue ( F )
inline

Definition at line 133 of file automation.h.

◆ TemplatableValue() [6/8]

template<typename T , typename... X>
template<typename F >
requires std::invocable<F, X...> && (!std::convertible_to<F, T (*)(X...)>) &&(!std::is_empty_v<F> || !std::convertible_to<std::invoke_result_t<F, X...>, T> || !std::default_initializable<F>)
esphome::TemplatableValue< T, X >::TemplatableValue ( F )
delete

◆ TemplatableValue() [7/8]

template<typename T , typename... X>
esphome::TemplatableValue< T, X >::TemplatableValue ( const TemplatableValue< T, X > & other)
inline

Definition at line 146 of file automation.h.

◆ TemplatableValue() [8/8]

template<typename T , typename... X>
esphome::TemplatableValue< T, X >::TemplatableValue ( TemplatableValue< T, X > && other)
inlinenoexcept

Definition at line 154 of file automation.h.

◆ ~TemplatableValue()

template<typename T , typename... X>
esphome::TemplatableValue< T, X >::~TemplatableValue ( )
inline

Definition at line 192 of file automation.h.

Member Function Documentation

◆ destroy_()

template<typename T , typename... X>
void esphome::TemplatableValue< T, X >::destroy_ ( )
inlineprotected

Definition at line 217 of file automation.h.

◆ has_value()

template<typename T , typename... X>
bool esphome::TemplatableValue< T, X >::has_value ( ) const
inline

Definition at line 194 of file automation.h.

◆ operator=() [1/2]

template<typename T , typename... X>
TemplatableValue & esphome::TemplatableValue< T, X >::operator= ( const TemplatableValue< T, X > & other)
inline

Definition at line 164 of file automation.h.

◆ operator=() [2/2]

template<typename T , typename... X>
TemplatableValue & esphome::TemplatableValue< T, X >::operator= ( TemplatableValue< T, X > && other)
inlinenoexcept

Definition at line 177 of file automation.h.

◆ optional_value()

template<typename T , typename... X>
optional< T > esphome::TemplatableValue< T, X >::optional_value ( X... x) const
inline

Definition at line 204 of file automation.h.

◆ value()

template<typename T , typename... X>
T esphome::TemplatableValue< T, X >::value ( X... x) const
inline

Definition at line 196 of file automation.h.

◆ value_or()

template<typename T , typename... X>
T esphome::TemplatableValue< T, X >::value_or ( X... x,
T default_value ) const
inline

Definition at line 210 of file automation.h.

Field Documentation

◆ NONE

template<typename T , typename... X>
enum esphome::TemplatableValue::Tag esphome::TemplatableValue< T, X >::NONE
protected

◆ storage_

template<typename T , typename... X>
union esphome::TemplatableValue::Storage esphome::TemplatableValue< T, X >::storage_
protected

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