libMesh
Public Types | Public Member Functions | Protected Member Functions | List of all members
libMesh::safe_bool_base Class Reference

This is a helper class which can be used to make pre-C++11 operator bool() comparisons safer by making them behave a bit more like they have the "explicit" keyword attached. More...

#include <safe_bool.h>

Inheritance diagram for libMesh::safe_bool_base:
[legend]

Public Types

typedef void(safe_bool_base::* bool_type) () const
 

Public Member Functions

void this_type_does_not_support_comparisons () const
 

Protected Member Functions

 safe_bool_base ()
 
 safe_bool_base (const safe_bool_base &)
 
safe_bool_baseoperator= (const safe_bool_base &)
 
 ~safe_bool_base ()
 

Detailed Description

This is a helper class which can be used to make pre-C++11 operator bool() comparisons safer by making them behave a bit more like they have the "explicit" keyword attached.

The idea is to define your class using the CRTP idiom and implement the non-virtual boolean_test() function, e.g.:

class Foo : public safe_bool<Foo> { public: bool boolean_test() const { // Perform actual logic here to determine true/false return value. return false; } };

The idea is from: https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Safe_bool

Definition at line 44 of file safe_bool.h.

Member Typedef Documentation

typedef void(safe_bool_base::* libMesh::safe_bool_base::bool_type) () const

Definition at line 47 of file safe_bool.h.

Constructor & Destructor Documentation

libMesh::safe_bool_base::safe_bool_base ( )
protected

Definition at line 51 of file safe_bool.h.

51 {}
libMesh::safe_bool_base::safe_bool_base ( const safe_bool_base )
protected

Definition at line 52 of file safe_bool.h.

52 {}
libMesh::safe_bool_base::~safe_bool_base ( )
protected

Definition at line 54 of file safe_bool.h.

54 {}

Member Function Documentation

safe_bool_base& libMesh::safe_bool_base::operator= ( const safe_bool_base )
protected

Definition at line 53 of file safe_bool.h.

53 {return *this;}
void libMesh::safe_bool_base::this_type_does_not_support_comparisons ( ) const

The documentation for this class was generated from the following file: