14#ifndef IOX2_BB_VOCABULARY_EXPECTED_HELPER_HPP
15#define IOX2_BB_VOCABULARY_EXPECTED_HELPER_HPP
49template <
typename T =
void>
53 explicit ok(
const T& t) noexcept
58 template <
typename U = T,
typename = enable_if_not_lvalue_referece_t<U>>
60 explicit ok(T&& t) noexcept
61 :
value(std::forward<T>(t)) {
65 template <
typename... Targs>
66 explicit ok(Targs&&... args) noexcept
67 :
value(std::forward<Targs>(args)...) {
85 explicit err(
const T& t) noexcept
90 template <
typename U = T,
typename = enable_if_not_lvalue_referece_t<U>>
92 explicit err(T&& t) noexcept
93 :
value(std::forward<T>(t)) {
96 template <
typename... Targs>
97 explicit err(Targs&&... args) noexcept
98 :
value(std::forward<Targs>(args)...) {
105template <
typename ValueType,
typename ErrorType>
110 template <typename... Targs>
112 : data(
in_place_index<VALUE_INDEX>(), std::forward<Targs>(args)...) {
115 template <
typename... Targs>
118 : data(
in_place_index<ERROR_INDEX>(), std::forward<Targs>(args)...) {
122 return data.index() == VALUE_INDEX;
126 return data.index() == ERROR_INDEX;
130 return *data.template get_at_index<VALUE_INDEX>();
134 return *data.template get_at_index<VALUE_INDEX>();
138 return *data.template get_at_index<ERROR_INDEX>();
142 return *data.template get_at_index<ERROR_INDEX>();
146 static constexpr uint64_t VALUE_INDEX { 0 };
147 static constexpr uint64_t ERROR_INDEX { 1 };
153template <
typename ErrorType>
158 template <typename... Targs>
164 template <
typename... Targs>
166 : data(
in_place_index<ERROR_INDEX>(), std::forward<Targs>(args)...) {
170 return data.index() == VALUE_INDEX;
174 return data.index() == ERROR_INDEX;
182 return *data.template get_at_index<ERROR_INDEX>();
186 return *data.template get_at_index<ERROR_INDEX>();
190 static constexpr uint64_t VALUE_INDEX { 0 };
191 static constexpr uint64_t ERROR_INDEX { 1 };
193 using DummyValueType = bool;
194 static constexpr DummyValueType
DUMMY_VALUE {
true };
199template <
typename ErrorType>
203template <
typename T,
typename E>
expected_storage(unexpect_t, Targs &&... args)
const ErrorType & error_unchecked() const
ErrorType & error_unchecked()
expected_storage() noexcept=delete
void value_unchecked() const
helper class to be able to handle 'void' value type specialization
const ErrorType & error_unchecked() const
ValueType & value_unchecked()
expected_storage() noexcept=delete
const ValueType & value_unchecked() const
ErrorType & error_unchecked()
expected_storage(unexpect_t, Targs &&... args)
Variant implementation from the C++17 standard with C++11. The interface is inspired by the C++17 sta...
constexpr expected_storage< void, ErrorType >::DummyValueType expected_storage< void, ErrorType >::DUMMY_VALUE
constexpr in_place_t in_place
constexpr unexpect_t unexpect
typename std::enable_if< std::is_void< T >::value, T >::type enable_if_void_t
helper trait for SFINEA to disable specific functions for non 'void' value type
typename std::enable_if<!std::is_void< T >::value, T >::type enable_if_non_void_t
helper trait for SFINEA to disable specific functions for 'void' value type
typename std::enable_if<!std::is_lvalue_reference< T >::value, T >::type enable_if_not_lvalue_referece_t
helper trait for SFINEA to disable specific functions for lvalue references
static constexpr bool is_same_value_unchecked(const expected_storage< void, E > &, const expected_storage< void, E > &)
helper struct for 'operator==' to be able to handle 'void' value type specialization
static constexpr bool is_same_value_unchecked(const expected_storage< T, E > &lhs, const expected_storage< T, E > &rhs)
err(Targs &&... args) noexcept
ok(Targs &&... args) noexcept
helper struct to perform an emplacement at a predefined index in the constructor of a variant
helper struct which is used to call the in-place-construction constructor
helper struct which is used to call the in-place-construction constructor for error types