Lancaster University's fork of the mbed BLE API. Lives on github, https://github.com/lancaster-university/BLE_API

Dependents:   microbit-dal microbit-dal microbit-ble-open microbit-dal ... more

Fork of BLE_API by Bluetooth Low Energy

Embed: (wiki syntax)

« Back to documentation index

SafeBool< T > Class Template Reference

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.

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:
TType 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 89 of file SafeBool.h.


Member Function Documentation

operator BoolType_t (  ) const

bool operator implementation, derived class has to provide bool toBool() const function.

Definition at line 94 of file SafeBool.h.