5#ifndef ICE_UTIL_OPTIONAL_H
6#define ICE_UTIL_OPTIONAL_H
8#ifndef ICE_CPP11_MAPPING
12namespace IceUtilInternal
25const IceUtilInternal::NoneType
None = {};
45 Optional(IceUtilInternal::NoneType) : _isSet(false)
210 operator bool()
const
230 std::swap(_isSet, other._isSet);
231 std::swap(_value, other._value);
243 void checkIsSet()
const
247 throwOptionalNotSetException(__FILE__, __LINE__);
251 void throwOptionalNotSetException(
const char *,
int)
const;
269template<
typename T>
inline void
270Optional<T>::throwOptionalNotSetException(
const char* file,
int line)
const
272 throw OptionalNotSetException(file, line);
276template<
typename T,
typename U>
289template<
typename T,
typename U>
295template<
typename T,
typename U>
308template<
typename T,
typename U>
311 return lhs < rhs || lhs == rhs;
314template<
typename T,
typename U>
317 return !(lhs < rhs || lhs == rhs);
320template<
typename T,
typename U>
328template<
typename T,
typename Y>
341template<
typename T,
typename Y>
347template<
typename T,
typename Y>
360template<
typename T,
typename Y>
363 return lhs < rhs || lhs == rhs;
366template<
typename T,
typename Y>
369 return !(lhs < rhs || lhs == rhs);
372template<
typename T,
typename Y>
380template<
typename T,
typename Y>
393template<
typename T,
typename Y>
399template<
typename T,
typename Y>
412template<
typename T,
typename Y>
415 return lhs < rhs || lhs == rhs;
418template<
typename T,
typename Y>
421 return !(lhs < rhs || lhs == rhs);
424template<
typename T,
typename Y>
Encapsulates an optional value, which may or may not be present.
Definition Optional.h:30
Optional(const Optional &r)
Constructs an optional as a copy of the given optional.
Definition Optional.h:53
void swap(Optional &other)
Exchanges the state of this optional with another one.
Definition Optional.h:228
T & operator*()
Obtains the current value.
Definition Optional.h:201
T * operator->()
Obtains a pointer to the current value.
Definition Optional.h:181
T & get()
Obtains the current value.
Definition Optional.h:161
const T & get() const
Obtains the current value.
Definition Optional.h:151
Optional(const Optional< Y > &r)
Constructs an optional as a copy of the given optional.
Definition Optional.h:71
T element_type
Definition Optional.h:33
T & value()
Obtains the current value.
Definition Optional.h:140
bool operator!() const
Determines whether this optional has a value.
Definition Optional.h:219
Optional & operator=(const Optional< Y > &r)
Resets this optional to be a copy of the given optional.
Definition Optional.h:106
Optional & operator=(const Optional &r)
Resets this optional to be a copy of the given optional.
Definition Optional.h:117
Optional & operator=(IceUtilInternal::NoneType)
Resets this optional to have no value.
Definition Optional.h:82
Optional(IceUtilInternal::NoneType)
Constructs an empty optional with no value.
Definition Optional.h:45
Optional(Y p)
Constructs an optional with the given value.
Definition Optional.h:62
const T & value() const
Obtains the current value.
Definition Optional.h:129
Optional()
Constructs an empty optional with no value.
Definition Optional.h:38
const T * operator->() const
Obtains a pointer to the current value.
Definition Optional.h:171
~Optional()
Definition Optional.h:75
const T & operator*() const
Obtains the current value.
Definition Optional.h:191
Optional & operator=(Y p)
Resets this optional to have the given value.
Definition Optional.h:94
bool operator>(const HandleBase< T > &lhs, const HandleBase< U > &rhs)
Definition Handle.h:130
bool operator<(const HandleBase< T > &lhs, const HandleBase< U > &rhs)
Definition Handle.h:109
const IceUtilInternal::NoneType None
A sentinel value used to indicate that no optional value was provided.
Definition Optional.h:25
bool operator<=(const HandleBase< T > &lhs, const HandleBase< U > &rhs)
Definition Handle.h:124
bool operator>=(const HandleBase< T > &lhs, const HandleBase< U > &rhs)
Definition Handle.h:136
Optional< T > makeOptional(const T &v)
Constructs an optional from the given value.
Definition Optional.h:263
bool operator!=(const HandleBase< T > &lhs, const HandleBase< U > &rhs)
Definition Handle.h:103
bool operator==(const HandleBase< T > &lhs, const HandleBase< U > &rhs)
Definition Handle.h:88