LibSWOC++ 1.5.14
Solid Wall of C++
Loading...
Searching...
No Matches
swoc::meta::let< T > Struct Template Reference

#include <swoc_meta.h>

Collaboration diagram for swoc::meta::let< T >:
Collaboration graph

Public Types

using self_type = let
 

Public Member Functions

 let (self_type const &that)=delete
 
self_typeoperator= (self_type const &)=delete
 
 let (T &var, T const &value)
 
 let (T &var, T &&value)
 

Public Attributes

T & _var
 Reference to scoped variable.
 
_value
 Original value.
 

Detailed Description

template<typename T>
struct swoc::meta::let< T >

Scoped value change.

The purpose of this class is to change the value of a variable in a scope and then change it back when the scope is exited. The old value will be moved to a cache variable and then moved back when the instance is destructed. This is very useful to temporarily tweak global variables which having to know what the current value is.

{
let save(var, value);
// var now has value.
}
// var now has original value.
Template Parameters
TType of variable to scope.

Definition at line 257 of file swoc_meta.h.

Member Typedef Documentation

◆ self_type

template<typename T>
using swoc::meta::let< T >::self_type = let

Definition at line 258 of file swoc_meta.h.

Constructor & Destructor Documentation

◆ let() [1/2]

template<typename T>
swoc::meta::let< T >::let ( T & var,
T const & value )

Construct a scope.

Parameters
varVariable to scope.
valuetemporary value to assign.

Definition at line 283 of file swoc_meta.h.

◆ let() [2/2]

template<typename T>
swoc::meta::let< T >::let ( T & var,
T && value )

Construct a scope.

Parameters
varVariable to scope.
valuetemporary value to assign.

Definition at line 286 of file swoc_meta.h.

◆ ~let()

template<typename T>
swoc::meta::let< T >::~let ( )

Definition at line 290 of file swoc_meta.h.

Member Data Documentation

◆ _value

template<typename T>
T swoc::meta::let< T >::_value

Original value.

Definition at line 264 of file swoc_meta.h.

◆ _var

template<typename T>
T& swoc::meta::let< T >::_var

Reference to scoped variable.

Definition at line 263 of file swoc_meta.h.


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