Pico-Framework
A web-first embedded framework for C++
Loading...
Searching...
No Matches
WithFlag.h
Go to the documentation of this file.
1
15
#pragma once
16
21
class
WithFlag
{
22
bool
&
flag
;
23
bool
previousValue
;
24
25
public
:
31
explicit
WithFlag
(
bool
&
flag
,
bool
value =
true
)
32
:
flag
(
flag
),
previousValue
(
flag
) {
33
flag
= value;
34
}
35
39
~WithFlag
() {
40
flag
=
previousValue
;
41
}
42
};
43
WithFlag
Temporarily sets a boolean flag and restores it automatically.
Definition
WithFlag.h:21
WithFlag::flag
bool & flag
Definition
WithFlag.h:22
WithFlag::WithFlag
WithFlag(bool &flag, bool value=true)
Construct the WithFlag and set the flag to the desired value (default true).
Definition
WithFlag.h:31
WithFlag::previousValue
bool previousValue
Definition
WithFlag.h:23
WithFlag::~WithFlag
~WithFlag()
Destructor restores the original value of the flag.
Definition
WithFlag.h:39
utility
WithFlag.h
Generated by
1.9.8