Forward declaration. More...
Public Types | |
typedef T | ValueType |
An alias for a type of the value represented by this class. More... | |
Public Member Functions | |
Nullable () | |
Constructs an instance that represents null-value. More... | |
Nullable (std::nullptr_t) | |
Constructs an instance that represents null. More... | |
template<typename T1 > | |
Nullable (const T1 &value) | |
template<typename T1 > | |
Nullable (const Nullable< T1 > &value) | |
template<typename T1 , typename = typename std::enable_if<std::is_null_pointer<T1>::value>> | |
Nullable< T > | operator= (std::nullptr_t) |
template<typename T1 > | |
std::enable_if<!IsNullable< T1 >::value &&!std::is_null_pointer< T1 >::value, Nullable< T > & >::type | operator= (const T1 &x) |
template<typename T1 > | |
Nullable< T > & | operator= (const Nullable< T1 > &x) |
T | get_Value () const |
bool | get_HasValue () const |
operator const T & () const | |
void | reset () |
Sets the currently represented value to null. More... | |
bool | IsNull () const |
template<typename T1 > | |
bool | NullableBoolHelper (const T1 &other, const std::function< bool()> &f, bool default_if_both_are_null=false) const |
bool | operator== (std::nullptr_t) const |
template<typename T1 > | |
std::enable_if<!IsNullable< T1 >::value, bool >::type | operator== (const T1 &other) const |
template<typename T1 > | |
bool | operator== (const Nullable< T1 > &other) const |
template<typename T1 > | |
std::enable_if< IsNullable< T1 >::value, bool >::type | Equals (const T1 &other) const |
bool | operator!= (std::nullptr_t) const |
template<typename T1 > | |
std::enable_if<!IsNullable< T1 >::value, bool >::type | operator!= (const T1 &other) const |
template<typename T1 > | |
bool | operator!= (const Nullable< T1 > &other) const |
bool | operator> (std::nullptr_t) const |
Always returns false. More... | |
template<typename T1 > | |
std::enable_if<!IsNullable< T1 >::value, bool >::type | operator> (const T1 &other) const |
template<typename T1 > | |
bool | operator> (const Nullable< T1 > &other) const |
bool | operator< (std::nullptr_t) const |
Always returns false. More... | |
template<typename T1 > | |
std::enable_if<!IsNullable< T1 >::value, bool >::type | operator< (const T1 &other) const |
template<typename T1 > | |
bool | operator< (const Nullable< T1 > &other) const |
bool | operator>= (std::nullptr_t) const |
template<typename T1 > | |
std::enable_if<!IsNullable< T1 >::value, bool >::type | operator>= (const T1 &other) const |
template<typename T1 > | |
bool | operator>= (const Nullable< T1 > &other) const |
bool | operator<= (std::nullptr_t) const |
Always returns false. More... | |
template<typename T1 > | |
std::enable_if<!IsNullable< T1 >::value, bool >::type | operator<= (const T1 &other) const |
template<typename T1 > | |
bool | operator<= (const Nullable< T1 > &other) const |
Nullable< T > | operator+ (std::nullptr_t) const |
Returns a default constructed instance of Nullable<T> class. More... | |
template<typename T1 , typename = typename std::enable_if<!IsNullable<T1>::value, int>::type> | |
auto | operator+ (const T1 &other) const -> Nullable< decltype(get_Value()+other)> |
template<typename T1 > | |
auto | operator+ (const Nullable< T1 > &other) const -> System::Nullable< decltype(get_Value()+other.get_Value())> |
template<typename T1 , typename = typename std::enable_if<std::is_null_pointer<T1>::value>::type> | |
Nullable< T > | operator- (T1) const |
template<typename T1 , typename = typename std::enable_if<!IsNullable<T1>::value, int>::type> | |
auto | operator- (const T1 &other) const -> Nullable< decltype(get_Value() - other)> |
template<typename T1 > | |
auto | operator- (const Nullable< T1 > &other) const -> System::Nullable< decltype(get_Value() - other.get_Value())> |
Nullable< T > | operator+= (std::nullptr_t) |
template<typename T1 > | |
std::enable_if<!IsNullable< T1 >::value, Nullable< T > >::type | operator+= (const T1 &other) |
template<typename T1 > | |
Nullable< T > | operator+= (const Nullable< T1 > &other) |
template<typename T1 , typename = typename std::enable_if<std::is_null_pointer<T1>::value>::type> | |
Nullable< T > | operator-= (T1) |
Returns an instance of Nullable class that represents a null-value. More... | |
template<typename T1 , typename = typename std::enable_if<!std::is_null_pointer<T1>::value, T1>::type> | |
std::enable_if<!IsNullable< T1 >::value, Nullable< T > >::type | operator-= (const T1 &other) |
template<typename T1 = T> | |
std::enable_if< std::is_same< T1, bool >::value, Nullable< T > >::type | operator|= (bool other) |
template<typename T1 = T> | |
std::enable_if< std::is_same< T1, bool >::value, Nullable< T > >::type | operator &= (bool other) |
template<typename T1 > | |
Nullable< T > | operator-= (const Nullable< T1 > &other) |
int | GetHashCode () const |
Returns a hash code for the current object. More... | |
String | ToString () const |
T | GetValueOrDefault (T default_value) |
T | GetValueOrDefault () |
Forward declaration.
Represents a value of the specified type that can be assigned null. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type.
T | The underlying value type which is extended by the Nullable class #include "system/nullable.h" #include <iostream> int main() { using NullableInt = System::Nullable<int>; // Create a lambda function that is used to print a value. const auto printLambda = [](const NullableInt &nullable) -> void { if (nullable.get_HasValue()) { std::cout << nullable.get_Value() << std::endl; } else { std::cout << "null" << std::endl; } }; // Create an instance of Nullable that doesn't contain any value and try to print it using the created lambda. NullableInt nullable; printLambda(nullable); // Assign the value to the instance of Nullable and print it using the created lambda. nullable = 15; printLambda(nullable); return 0; } /* * This code example produces the following output: * null * 15 */ |
typedef T System::Nullable< T >::ValueType |
An alias for a type of the value represented by this class.
|
inline |
Constructs an instance that represents null-value.
|
inline |
Constructs an instance that represents null.
|
inline |
Constructs an instance of Nullable class that represents the specified value converted (if necessary) to the value of the underlying type T.
value | A constant reference to the value to be represented by the newly constructed Nullable object |
T1 | The type of the specified value |
|
inline |
Constructs an instance that represents a value that is represented by the specified Nullable object. The specified nullable object may represent a value of different type than the underlying type of the constructed instance in which case the represented value is converted to a value of type T.
T1 | The type of the value represented by the specified Nullable object |
|
inline |
Determines if the value represented by the current object is equal to the value represented by the specified Nullable object.
other | A constant reference to the Nullable object to compare with |
T1 | The underlying type of the Nullable object to compare with |
|
inline |
Determines whether the current object represents any value.
|
inline |
Returns a copy of the value represented by the current object.
InvalidOperationException | If the current object does not represent any value |
|
inline |
Returns a hash code for the current object.
|
inline |
Returns the value represented by the current object or the specified value if the value represented by the current object is null.
default_value | The value returned by the method if the value represented by the current object is null |
|
inline |
|
inline |
Determines if the current object represents a null-value.
|
inline |
Helper function to check if this and other
are both not nulls and call a lambda if so. Used in implementation.s
T1 | Other nullable type. |
other | Other nullable value to compare to. |
f | Lambda to call if both this and other are not nulls. |
default_if_both_are_null | Return value if both values are nulls. |
this
or other
is null; default_if_both_are_null
if both are null; result of f
call if both are not null.
|
inline |
Applies operator&=() to the value represented by the current object using the specified value as a right-side argument.
other | A boolean value that is used as a right-side value of the operator&=() applied to the value represented by the current object. |
T1 | The template parameter to make SFINAE work. |
|
inline |
Returns a constant reference to the value represented by the current object.
InvalidOperationException | If the current object does not represent any value |
|
inline |
Determines if the value represented by the current object is not null.
|
inline |
Determines if the value represented by the current object is not equal to the specified value.
other | A constant reference to the value to compare with |
T1 | The type of the value to compare with |
|
inline |
Determines if the value represented by the current object is not equal to the value represented by the specified Nullable object.
other | A constant reference to the Nullable object to compare with |
T1 | The underlying type of the Nullable object to compare with |
|
inline |
Returns a default constructed instance of Nullable<T> class.
|
inline |
Sums nullable and non-nullable values.
T1 | Right operand type. |
other | value to add. |
|
inline |
Sums nullable values.
T1 | Right operand type. |
other | value to add. |
|
inline |
Resets the current object so that it represents a null-value.
|
inline |
Applies operator+=() to the value represented by the current object using the specified value as a right-side argument.
other | A constant reference to the value that is used as a right-side value of the operator+=() applied to the value represented by the current object. |
T1 | The type of the value used as the right-side value of operator+=() |
|
inline |
Applies operator+=() to the value represented by the current object using the value represented by the specified Nullable object as the right-side argument.
other | A constant reference to Nullable object the value represented by which is used as a right-side argument of the operator+=() applied to the value represented by the current object. |
T1 | The underlying type of a Nullable object the value represented by which is used as the right-side argument of operator+=() |
|
inline |
Subtracts nullable and null-pointed values.
T1 | Right operand type, should be nullptr_t. |
|
inline |
Subtracts nullable and non-nullable values.
T1 | Right operand type. |
other | value to subtract. |
|
inline |
Subtracts nullable values.
T1 | Right operand type. |
other | value to subtract. |
|
inline |
Returns an instance of Nullable class that represents a null-value.
|
inline |
Applies operator-=() to the value represented by the current object using the specified value as a right-side argument.
other | A constant reference to the value that is used as a right-side value of the operator-=() applied to the value represented by the current object. |
T1 | The type of the value used as the right-side value of operator-=() |
|
inline |
Applies operator-=() to the value represented by the current object using the value represented by the specified Nullable object as the right-side argument.
other | A constant reference to Nullable object the value represented by which is used as a right-side argument of the operator-=() applied to the value represented by the current object. |
T1 | The underlying type of a Nullable object the value represented by which is used as the right-side argument of operator-=() |
|
inline |
Always returns false.
|
inline |
Determines if the value represented by the current object is less than the specified value by applying operator<() to these values.
other | A constant reference to the value to compare with |
T1 | The type of the value to compare with |
|
inline |
Determines if the value represented by the current object is less than the value represented by the specified Nullable object by applying operator<() to these values.
other | A constant reference to the Nullable object to compare with |
T1 | The underlying type of the Nullable object to compare with |
|
inline |
Always returns false.
|
inline |
Determines if the value represented by the current object is less or equal to the specified value by applying operator<=() to these values.
other | A constant reference to the value to compare with |
T1 | The type of the value to compare with |
|
inline |
Determines if the value represented by the current object is less or equal to the value represented by the specified Nullable object by applying operator<=() to these values.
other | A constant reference to the Nullable object to compare with |
T1 | The underlying type of the Nullable object to compare with |
|
inline |
Assigns a null to the current object.
|
inline |
Replaces the object's currently represented value with the specified one.
x | The new value to be represented by the current object |
The | type of the new value to be represented by the current object |
|
inline |
Replaces the object's currently represented value with the specified one.
x | The new value to be represented by the current object |
The | type of the new value to be represented by the current object |
|
inline |
Determines if the value represented by the current object is null.
|
inline |
Determines if the value represented by the current object is equal to the specified value.
other | A constant reference to the value to compare with |
T1 | The type of the value to compare with |
|
inline |
Determines if the value represented by the current object is equal to the value represented by the specified Nullable object.
other | A constant reference to the Nullable object to compare with |
T1 | The underlying type of the Nullable object to compare with |
|
inline |
Always returns false.
|
inline |
Determines if the value represented by the current object is greater than the specified value by applying operator>() to these values.
other | A constant reference to the value to compare with |
T1 | The type of the value to compare with |
|
inline |
Determines if the value represented by the current object is greater than the value represented by the specified Nullable object by applying operator>() to these values.
other | A constant reference to the Nullable object to compare with |
T1 | The underlying type of the Nullable object to compare with |
|
inline |
Always returns false.
|
inline |
Determines if the value represented by the current object is greater or equal to the value represented by the specified object by applying operator>=() to these values.
other | A constant reference to an object to compare the current object with |
T1 | The underlying type of the value to compare the value represented by the current object with |
|
inline |
Determines if the value represented by the current object is greater or equal to the value represented by the specified Nullable object by applying operator>=() to these values.
other | A constant reference to the Nullable object to compare with |
T1 | The underlying type of the Nullable object to compare with |
|
inline |
Applies operator|=() to the value represented by the current object using the specified value as a right-side argument.
other | A boolean value that is used as a right-side value of the operator|=() applied to the value represented by the current object. |
T1 | The template parameter to make SFINAE work. |
|
inline |
Sets the currently represented value to null.
|
inline |
Converts the value represented by the current object to string.