xtd 1.0.0
Loading...
Searching...
No Matches
optional.hpp File Reference
#include <optional>
#include "generic_stream_output.hpp"

Definition

Contains xtd::optional type.

Go to the source code of this file.

Namespaces

namespace  xtd
 The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.

Typedefs

template<typename type_t>
using xtd::optional
 Represents the optional alias on std::optional.

Functions

template<typename optional_t, typename default_value_t>
optional_t operator| (const xtd::optional< optional_t > &optional, default_value_t &&default_value)
 Gets the contained value of specified optional if available; otherwhise the specified default_value.
template<typename optional_t, typename default_value_t>
xtd::optional< optional_t > & operator|= (xtd::optional< optional_t > &optional, default_value_t &&default_value)
 Sets the default value if the contained value of specified optional i empty (equal to xtd::nullopt)..

Function Documentation

◆ operator|()

template<typename optional_t, typename default_value_t>
optional_t operator| ( const xtd::optional< optional_t > & optional,
default_value_t && default_value )

Gets the contained value of specified optional if available; otherwhise the specified default_value.

Parameters
optionalThe optional to gets the value.
default_valueThe default value if optioanl is empty.
Returns
The contained value of optional if available; otherwise the default value.
Examples
enum_class_flags_without_helpers.cpp, and format_enum_class_flags_without_helper.cpp.

◆ operator|=()

template<typename optional_t, typename default_value_t>
xtd::optional< optional_t > & operator|= ( xtd::optional< optional_t > & optional,
default_value_t && default_value )

Sets the default value if the contained value of specified optional i empty (equal to xtd::nullopt)..

Parameters
optionalThe optional to sets the value.
default_valueThe default value to set t optional if optioanl is empty.
Returns
The optional updated if empty otherwise; option not updated.