Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SafeBool< T > Class Template Reference
template class SafeBool use CRTP to made boolean conversion easy and correct. More...
#include <SafeBool.h>
Inherits SafeBool_::base.
Public Member Functions | |
| operator BoolType_t () const | |
| Bool operator implementation, derived class has to provide bool toBool() const function. | |
Protected Types | |
| typedef void(base::* | BoolType_t )() const |
| The bool type is a pointer to method which can be used in boolean context. | |
Protected Member Functions | |
| void | invalidTag () const |
| Non implemented call, use to disallow conversion between unrelated types. | |
| void | trueTag () const |
| Member function which indicate true value. | |
Detailed Description
template<typename T>
class SafeBool< T >
template class SafeBool use CRTP to made boolean conversion easy and correct.
Derived class should implement the function bool toBool() const to make this work. Inheritance should be public.
- Template Parameters:
-
T Type of the derived class
class A : public SafeBool<A> { public: // boolean conversion bool toBool() { } }; 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 95 of file SafeBool.h.
Member Typedef Documentation
typedef void(base::* BoolType_t)() const [protected, inherited] |
The bool type is a pointer to method which can be used in boolean context.
Definition at line 35 of file SafeBool.h.
Member Function Documentation
| void invalidTag | ( | ) | const [protected, inherited] |
Non implemented call, use to disallow conversion between unrelated types.
| operator BoolType_t | ( | ) | const |
Bool operator implementation, derived class has to provide bool toBool() const function.
Definition at line 100 of file SafeBool.h.
| void trueTag | ( | ) | const [protected, inherited] |
Member function which indicate true value.
Definition at line 45 of file SafeBool.h.
Generated on Tue Jul 12 2022 13:06:11 by
1.7.2