Ice 3.7 C++98 API Reference
Loading...
Searching...
No Matches
IceUtil::Optional< T > Class Template Reference

Encapsulates an optional value, which may or may not be present. More...

#include <Optional.h>

Public Types

typedef T element_type

Public Member Functions

T & get ()
 Obtains the current value.
const T & get () const
 Obtains the current value.
 operator bool () const
 Determines whether this optional has a value.
bool operator! () const
 Determines whether this optional has a value.
T & operator* ()
 Obtains the current value.
const T & operator* () const
 Obtains the current value.
T * operator-> ()
 Obtains a pointer to the current value.
const T * operator-> () const
 Obtains a pointer to the current value.
Optionaloperator= (const Optional &r)
 Resets this optional to be a copy of the given optional.
template<typename Y>
Optionaloperator= (const Optional< Y > &r)
 Resets this optional to be a copy of the given optional.
Optionaloperator= (IceUtilInternal::NoneType)
 Resets this optional to have no value.
template<typename Y>
Optionaloperator= (Y p)
 Resets this optional to have the given value.
 Optional ()
 Constructs an empty optional with no value.
 Optional (const Optional &r)
 Constructs an optional as a copy of the given optional.
template<typename Y>
 Optional (const Optional< Y > &r)
 Constructs an optional as a copy of the given optional.
 Optional (IceUtilInternal::NoneType)
 Constructs an empty optional with no value.
template<typename Y>
 Optional (Y p)
 Constructs an optional with the given value.
void swap (Optional &other)
 Exchanges the state of this optional with another one.
T & value ()
 Obtains the current value.
const T & value () const
 Obtains the current value.
 ~Optional ()

Detailed Description

template<typename T>
class IceUtil::Optional< T >

Encapsulates an optional value, which may or may not be present.

Member Typedef Documentation

◆ element_type

template<typename T>
typedef T IceUtil::Optional< T >::element_type

Constructor & Destructor Documentation

◆ Optional() [1/5]

template<typename T>
IceUtil::Optional< T >::Optional ( )
inline

Constructs an empty optional with no value.

◆ Optional() [2/5]

template<typename T>
IceUtil::Optional< T >::Optional ( IceUtilInternal::NoneType )
inline

Constructs an empty optional with no value.

◆ Optional() [3/5]

template<typename T>
IceUtil::Optional< T >::Optional ( const Optional< T > & r)
inline

Constructs an optional as a copy of the given optional.

Parameters
rThe source optional.

◆ Optional() [4/5]

template<typename T>
template<typename Y>
IceUtil::Optional< T >::Optional ( Y p)
inline

Constructs an optional with the given value.

Parameters
pThe initial value.

◆ Optional() [5/5]

template<typename T>
template<typename Y>
IceUtil::Optional< T >::Optional ( const Optional< Y > & r)
inline

Constructs an optional as a copy of the given optional.

Parameters
rThe source optional.

◆ ~Optional()

template<typename T>
IceUtil::Optional< T >::~Optional ( )
inline

Member Function Documentation

◆ get() [1/2]

template<typename T>
T & IceUtil::Optional< T >::get ( )
inline

Obtains the current value.

Returns
The current value.
Exceptions
OptionalNotSetExceptionif this optional has no value.

◆ get() [2/2]

template<typename T>
const T & IceUtil::Optional< T >::get ( ) const
inline

Obtains the current value.

Returns
The current value.
Exceptions
OptionalNotSetExceptionif this optional has no value.

◆ operator bool()

template<typename T>
IceUtil::Optional< T >::operator bool ( ) const
inline

Determines whether this optional has a value.

Returns
True if the optional has a value, false otherwise.

◆ operator!()

template<typename T>
bool IceUtil::Optional< T >::operator! ( ) const
inline

Determines whether this optional has a value.

Returns
True if the optional does not have a value, false otherwise.

◆ operator*() [1/2]

template<typename T>
T & IceUtil::Optional< T >::operator* ( )
inline

Obtains the current value.

Returns
The current value.
Exceptions
OptionalNotSetExceptionif this optional has no value.

◆ operator*() [2/2]

template<typename T>
const T & IceUtil::Optional< T >::operator* ( ) const
inline

Obtains the current value.

Returns
The current value.
Exceptions
OptionalNotSetExceptionif this optional has no value.

◆ operator->() [1/2]

template<typename T>
T * IceUtil::Optional< T >::operator-> ( )
inline

Obtains a pointer to the current value.

Returns
A pointer to the current value.
Exceptions
OptionalNotSetExceptionif this optional has no value.

◆ operator->() [2/2]

template<typename T>
const T * IceUtil::Optional< T >::operator-> ( ) const
inline

Obtains a pointer to the current value.

Returns
A pointer to the current value.
Exceptions
OptionalNotSetExceptionif this optional has no value.

◆ operator=() [1/4]

template<typename T>
Optional & IceUtil::Optional< T >::operator= ( const Optional< T > & r)
inline

Resets this optional to be a copy of the given optional.

Parameters
rThe source optional.

◆ operator=() [2/4]

template<typename T>
template<typename Y>
Optional & IceUtil::Optional< T >::operator= ( const Optional< Y > & r)
inline

Resets this optional to be a copy of the given optional.

Parameters
rThe source optional.

◆ operator=() [3/4]

template<typename T>
Optional & IceUtil::Optional< T >::operator= ( IceUtilInternal::NoneType )
inline

Resets this optional to have no value.

◆ operator=() [4/4]

template<typename T>
template<typename Y>
Optional & IceUtil::Optional< T >::operator= ( Y p)
inline

Resets this optional to have the given value.

Parameters
pThe new value.

◆ swap()

template<typename T>
void IceUtil::Optional< T >::swap ( Optional< T > & other)
inline

Exchanges the state of this optional with another one.

Parameters
otherThe optional value with which to swap.

◆ value() [1/2]

template<typename T>
T & IceUtil::Optional< T >::value ( )
inline

Obtains the current value.

Returns
The current value.
Exceptions
OptionalNotSetExceptionif this optional has no value.

◆ value() [2/2]

template<typename T>
const T & IceUtil::Optional< T >::value ( ) const
inline

Obtains the current value.

Returns
The current value.
Exceptions
OptionalNotSetExceptionif this optional has no value.

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