Rtos API example
SafeBool< T > Class Template Reference
[Common]
Safe conversion of objects in boolean context. More...
#include <SafeBool.h>
Inherits SafeBool_::base.
Public Member Functions | |
operator BoolType_t () const | |
Bool operator implementation, derived class must provide a bool toBool() const function. | |
Protected Types | |
typedef void(base::* | BoolType_t )() const |
The bool type is a pointer to method that can be used in boolean context. | |
Protected Member Functions | |
void | invalidTag () const |
Nonimplemented call, use to disallow conversion between unrelated types. | |
void | trueTag () const |
Special member function that indicates a true value. |
Detailed Description
template<typename T>
class SafeBool< T >
Safe conversion of objects in boolean context.
Classes wanting evaluation of their instances in boolean context must derive publicly from this class rather than implementing the easy to misuse operator bool().
Descendant classes must implement the function bool toBool() const to enable the safe conversion in boolean context.
- Template Parameters:
-
T Type of the derived class
class A : public SafeBool<A> { public: // boolean conversion bool toBool() const { } }; class B : public SafeBool<B> { public: // boolean conversion bool toBool() const { } }; A a; B b; // will compile if(a) { } // compilation error if(a == b) { }
Definition at line 111 of file SafeBool.h.
Member Typedef Documentation
typedef void(base::* BoolType_t)() const [protected, inherited] |
The bool type is a pointer to method that can be used in boolean context.
Definition at line 48 of file SafeBool.h.
Member Function Documentation
void invalidTag | ( | ) | const [protected, inherited] |
Nonimplemented call, use to disallow conversion between unrelated types.
operator BoolType_t | ( | ) | const |
Bool operator implementation, derived class must provide a bool toBool() const function.
Definition at line 117 of file SafeBool.h.
void trueTag | ( | ) | const [protected, inherited] |
Special member function that indicates a true value.
Definition at line 58 of file SafeBool.h.
Generated on Sun Jul 17 2022 08:25:42 by 1.7.2