- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
/* a temporary boolean true value which changes the value of the referenced boolean variable to
true and to false on destruction, meant to be used for short-lived boolean changes*/
class tempTrue {
bool & bVal;
public:
tempTrue(bool & ref):bVal(ref){bVal = true;}
virtual ~tempTrue() { bVal = false; }
void toggle() { bVal = !bVal; }
};
class tempFalse {
bool & bVal;
public:
tempFalse(bool & ref):bVal(ref){bVal = false;}
virtual ~tempFalse() { bVal = true; }
void toggle() { bVal = !bVal; }
};
class tempToggle {
bool & bVal;
public:
tempToggle(bool & ref): bVal(ref){ bVal = !bVal;}
virtual ~tempToggle() { bVal = !bVal; }
};
class booleanInit {
public:
booleanInit(bool b):bVal(b) {}
operator bool & () { return bVal; }
operator const bool & () const { return bVal; }
private:
bool bVal;
};
class booleanTrue:public booleanInit {
public:
booleanTrue():booleanInit(true) {}
};
class booleanFalse:public booleanInit {
public:
booleanFalse():booleanInit(false) {}
};