17#ifndef IOX_HOOFS_CXX_OPTIONAL_HPP
18#define IOX_HOOFS_CXX_OPTIONAL_HPP
20#include "iceoryx_hoofs/cxx/function_ref.hpp"
21#include "iceoryx_hoofs/cxx/requires.hpp"
22#include "iceoryx_hoofs/cxx/types.hpp"
96 template <typename... Targs>
130 constexpr
bool operator==(const
optional<T>& rhs) const noexcept;
134 constexpr
bool operator==(const
nullopt_t&) const noexcept;
140 constexpr
bool operator!=(const
optional<T>& rhs) const noexcept;
144 constexpr
bool operator!=(const
nullopt_t&) const noexcept;
152 template <typename U = T>
159 const T* operator->() const noexcept;
165 const T& operator*() const noexcept;
171 T* operator->() noexcept;
177 T& operator*() noexcept;
181 constexpr explicit operator
bool() const noexcept;
193 template <typename... Targs>
229 template <typename U>
230 constexpr T
value_or(U&& default_value) const noexcept;
255 alignas(T) byte_t m_data[sizeof(T)];
256 bool m_hasValue{
false};
259 template <
typename... Targs>
260 void construct_value(Targs&&... args)
noexcept;
261 void destruct_value() noexcept;
269template <typename OptionalBaseType, typename... Targs>
270optional<OptionalBaseType> make_optional(Targs&&... args) noexcept;
274#include "iceoryx_hoofs/internal/cxx/optional.inl"
Definition: function_ref.hpp:34
Optional implementation from the C++17 standard with C++11. The interface is analog to the C++17 stan...
Definition: optional.hpp:69
T & emplace(Targs &&... args) noexcept
A new element is constructed by forwarding the arguments to the constructor of T. If the optional has...
optional & or_else(const cxx::function_ref< void()> &callable) noexcept
calls the provided callable if the optional does not contain a value
void reset() noexcept
Calls the destructor of T if the optional has a value. If the optional has no value,...
constexpr bool has_value() const noexcept
Will return true if the optional contains a value, otherwise false.
optional & and_then(const cxx::function_ref< void(T &)> &callable) noexcept
calls the provided callable with the optional value as arguments if the optional contains a value
T & value() &noexcept
Returns a reference to the underlying value. If the optional has no value the application terminates....
optional() noexcept
Creates an optional which has no value. If you access such an optional via .value() or the arrow oper...
constexpr T value_or(U &&default_value) const noexcept
If the optional contains a value a copy of that value is returned, otherwise the default_value is ret...
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:29
helper struct which is used to call the in-place-construction constructor
Definition: optional.hpp:40
Helper struct which is used to signal an empty optional. It is equivalent to no value.
Definition: optional.hpp:34