Evo C++ Library v0.5.1
Public Types | Public Member Functions | Static Public Attributes | List of all members
Bool Struct Reference

#include <evo/type.h>

Inheritance diagram for Bool:
Inheritance graph
[legend]

Detailed Description

Basic boolean type.

A basic Evo container for boolean values.

Public Types

typedef void EvoNullableType
 Identify as nullable type. More...
 
typedef bool Type
 Wrapped type (bool) More...
 

Public Member Functions

 Bool ()
 Constructor. More...
 
 Bool (const Bool &val)
 Copy constructor. More...
 
 Bool (bool val)
 Constructor. More...
 
int compare (const Nullable< bool > &val) const
 Comparison. More...
 
int compare (bool val) const
 Comparison. More...
 
bool & denull ()
 Clears null flag and returns value reference. More...
 
bool null () const
 Get whether null. More...
 
 operator SafeBoolType () const
 Safe (explicit) evaluation as bool type. More...
 
bool operator! () const
 Negation operator returns whether null or 0. More...
 
bool operator!= (const Nullable< bool > &val) const
 Inequality operator. More...
 
bool operator!= (bool val) const
 Inequality operator. More...
 
const bool & operator* () const
 Dereference for explicit conversion to underlying type (const). More...
 
bool & operator* ()
 Dereference for explicit conversion to underlying type. More...
 
bool operator< (const Nullable< bool > &val) const
 Less than operator. More...
 
bool operator< (bool val) const
 Less than operator. More...
 
bool operator<= (const Nullable< bool > &val) const
 Less than or equal operator. More...
 
bool operator<= (bool val) const
 Less than or equal operator. More...
 
Booloperator= (const Bool &val)
 Assignment operator. More...
 
Booloperator= (bool val)
 Assignment operator. More...
 
Booloperator= (ValNull)
 Assignment operator to set as null. More...
 
bool operator== (const Nullable< bool > &val) const
 Equality operator. More...
 
bool operator== (bool val) const
 Equality operator. More...
 
bool operator> (const Nullable< bool > &val) const
 Greater than operator. More...
 
bool operator> (bool val) const
 Greater than operator. More...
 
bool operator>= (const Nullable< bool > &val) const
 Greater than or equal operator. More...
 
bool operator>= (bool val) const
 Greater than or equal operator. More...
 
Nullable< bool > & set ()
 Set as null. More...
 
Nullable< bool > & set (const Nullable< bool > &src)
 Set as copy of given value. More...
 
Nullable< bool > & set (bool src)
 Set as given value. More...
 
bool valid () const
 Get whether valid (not null). More...
 
const bool & value () const
 Get underlying value (const). More...
 
bool & value ()
 Get underlying value. More...
 

Static Public Attributes

static const int BITS = 1
 Type size in bits (1) More...
 
static const int BYTES = sizeof(bool)
 Type size in bytes, usually 1. More...
 

Member Typedef Documentation

◆ EvoNullableType

typedef void EvoNullableType
inherited

Identify as nullable type.

◆ Type

typedef bool Type

Wrapped type (bool)

Constructor & Destructor Documentation

◆ Bool() [1/3]

Bool ( )
inline

Constructor.

◆ Bool() [2/3]

Bool ( const Bool val)
inline

Copy constructor.

Parameters
valValue to copy

◆ Bool() [3/3]

Bool ( bool  val)
inline

Constructor.

Parameters
valValue to set

Member Function Documentation

◆ compare() [1/2]

int compare ( const Nullable< bool > &  val) const
inlineinherited

Comparison.

Parameters
valValue to compare to
Returns
Result (<0 if this is less, 0 if equal, >0 if this is greater)

◆ compare() [2/2]

int compare ( bool  val) const
inlineinherited

Comparison.

  • If null, the result is always -1 as null compares as less than any non-null value
Parameters
valValue to compare to
Returns
Result (<0 if this is less, 0 if equal, >0 if this is greater)

◆ denull()

bool & denull ( )
inlineinherited

Clears null flag and returns value reference.

  • Value is unchanged, POD types default to 0 when null
  • Useful for updating the underlying value by reference
  • Note: Nullable<bool> template specialization returns by value instead of reference
Returns
Whether valid

◆ null()

bool null ( ) const
inlineinherited

Get whether null.

Returns
Whether null

◆ operator SafeBoolType()

operator SafeBoolType ( ) const
inlineinherited

Safe (explicit) evaluation as bool type.

  • This is called when object is directly evaluated as a bool, and is equivalent to: !operator!()
  • See SafeBool

◆ operator!()

bool operator! ( ) const
inlineinherited

Negation operator returns whether null or 0.

Returns
Whether null or 0

◆ operator!=() [1/2]

bool operator!= ( const Nullable< bool > &  val) const
inlineinherited

Inequality operator.

Parameters
valValue to compare to
Returns
Whether inequal

◆ operator!=() [2/2]

bool operator!= ( bool  val) const
inlineinherited

Inequality operator.

  • If null, the result is always true as null is not equal to any non-null value
Parameters
valValue to compare to
Returns
Whether inequal, true if null

◆ operator*() [1/2]

const bool & operator* ( ) const
inlineinherited

Dereference for explicit conversion to underlying type (const).

Alternative to value().

Returns
Underlying type value

◆ operator*() [2/2]

bool & operator* ( )
inlineinherited

Dereference for explicit conversion to underlying type.

Alternative to value().

Returns
Underlying type value

◆ operator<() [1/2]

bool operator< ( const Nullable< bool > &  val) const
inlineinherited

Less than operator.

  • If null, null is less than any non-null value
Parameters
valValue to compare to
Returns
Whether less than val

◆ operator<() [2/2]

bool operator< ( bool  val) const
inlineinherited

Less than operator.

  • If null, null is less than any non-null value
Parameters
valValue to compare to
Returns
Whether less than val

◆ operator<=() [1/2]

bool operator<= ( const Nullable< bool > &  val) const
inlineinherited

Less than or equal operator.

  • If null, null is less than or equal to any value
Parameters
valValue to compare to
Returns
Whether less than or equal to val, true if null

◆ operator<=() [2/2]

bool operator<= ( bool  val) const
inlineinherited

Less than or equal operator.

  • If null, null is less than or equal to any value
Parameters
valValue to compare to
Returns
Whether less than or equal to val, true if null

◆ operator=() [1/3]

Bool& operator= ( const Bool val)
inline

Assignment operator.

Parameters
valValue to copy
Returns
This

◆ operator=() [2/3]

Bool& operator= ( bool  val)
inline

Assignment operator.

Parameters
valValue to set
Returns
This

◆ operator=() [3/3]

Bool& operator= ( ValNull  )
inline

Assignment operator to set as null.

Returns
This

◆ operator==() [1/2]

bool operator== ( const Nullable< bool > &  val) const
inlineinherited

Equality operator.

Parameters
valValue to compare to
Returns
Whether equal

◆ operator==() [2/2]

bool operator== ( bool  val) const
inlineinherited

Equality operator.

  • If null, the result is always false as null is not equal to any non-null value
Parameters
valValue to compare to
Returns
Whether equal, false if null

◆ operator>() [1/2]

bool operator> ( const Nullable< bool > &  val) const
inlineinherited

Greater than operator.

  • If null, null is not greater than any non-null value
Parameters
valValue to compare to
Returns
Whether greater than val, false if null

◆ operator>() [2/2]

bool operator> ( bool  val) const
inlineinherited

Greater than operator.

  • If null, null is not greater than any non-null value
Parameters
valValue to compare to
Returns
Whether greater than val, false if null

◆ operator>=() [1/2]

bool operator>= ( const Nullable< bool > &  val) const
inlineinherited

Greater than or equal operator.

  • If null, null is not greater than any non-null value
Parameters
valValue to compare to
Returns
Whether greater than or equal to val

◆ operator>=() [2/2]

bool operator>= ( bool  val) const
inlineinherited

Greater than or equal operator.

  • If null, null is not greater than any non-null value
Parameters
valValue to compare to
Returns
Whether greater than or equal to val

◆ set() [1/3]

Nullable<bool >& set ( )
inlineinherited

Set as null.

Returns
This

◆ set() [2/3]

Nullable<bool >& set ( const Nullable< bool > &  src)
inlineinherited

Set as copy of given value.

Parameters
srcSource to copy
Returns
This

◆ set() [3/3]

Nullable<bool >& set ( bool  src)
inlineinherited

Set as given value.

Parameters
srcSource to set
Returns
This

◆ valid()

bool valid ( ) const
inlineinherited

Get whether valid (not null).

Returns
Whether valid

◆ value() [1/2]

const bool & value ( ) const
inlineinherited

Get underlying value (const).

Alternative to operator*().

Returns
Whether valid

◆ value() [2/2]

bool & value ( )
inlineinherited

Get underlying value.

Alternative to operator*().

Returns
Whether valid

Member Data Documentation

◆ BITS

const int BITS = 1
static

Type size in bits (1)

◆ BYTES

const int BYTES = sizeof(bool)
static

Type size in bytes, usually 1.


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