C++ API Library Reference  4.3.2-74-ge1d4cca
Public Functions | Public Static Functions | List of all members
Nullable< T > Class Template Reference

template<typename T>
class CSI::Nullable< T >

The Nullable class implements the concept of a null value for a given type T.

A nullable instance is immutable except through assignment or construction. The reason for immutability is to ensure that the encapsulated value, which is default initialized when the instance represents null, must not be changed without also changing the associated m_hasValue flag. If a mutable reference to the interior value were possible, then a consumer of the class could change the value of a "null" instance, and we would not be able to detect the change in order to update the m_hasValue flag, and it would then be possible to have two "null" instances with unequal values.

Public Functions

template<typename U >
As () const
 
template<typename U >
Nullable< U > Convert () const
 
template<typename U >
ConvertOr (U const &defaultValue) const
 
HashCode GetHashCode () const
 
bool HasValue () const
 
bool IsNull () const
 
 Nullable ()
 
 Nullable (T const &value)
 
bool operator!= (Nullable const &other) const
 
bool operator!= (T const &other) const
 
Nullableoperator= (T const &value)
 
bool operator== (Nullable const &other) const
 
bool operator== (T const &other) const
 
Value () const
 
T const & ValueByRef () const
 
ValueOr (T const &defaultValue) const
 
ValueOrDefault () const
 

Public Static Functions

static Nullable Null ()
 

Usage Description

U As ( ) const
inline
Nullable<U> Convert ( ) const
inline
U ConvertOr ( U const &  defaultValue) const
inline
HashCode GetHashCode ( ) const
inline
bool HasValue ( ) const
inline
bool IsNull ( ) const
inline
static Nullable Null ( )
inlinestatic
bool operator!= ( Nullable< T > const &  other) const
inline
bool operator!= ( T const &  other) const
inline
Nullable& operator= ( T const &  value)
inline
bool operator== ( Nullable< T > const &  other) const
inline
bool operator== ( T const &  other) const
inline
T Value ( ) const
inline
T const& ValueByRef ( ) const
inline
T ValueOr ( T const &  defaultValue) const
inline
T ValueOrDefault ( ) const
inline