29#ifdef ONIXS_ICEBOE_CXX17
37#ifdef ONIXS_ICEBOE_CXX17
43 enum class _Construct { _Token };
44 explicit constexpr NullOpt(_Construct)
noexcept {}
55template <
typename Derived>
59 template <
typename D = Derived>
60 ONIXS_ICEBOE_FORCEINLINE
61 auto value() const -> decltype(*std::declval<const
D&>())
63 if (!this_().hasValue())
69 ONIXS_ICEBOE_FORCEINLINE
70 static constexpr Derived
null() noexcept
75 explicit operator bool() const noexcept
77 return this_().hasValue();
80#ifdef ONIXS_ICEBOE_CXX17
81 template <
typename D = Derived>
82 using Native = std::optional<std::decay_t<decltype(*std::declval<const D&>())>>;
84 template <
typename D = Derived>
87 return this_().hasValue() ?
Native<D>(*this_()) : std::nullopt;
90 template <
typename D = Derived>
101 ONIXS_ICEBOE_FORCEINLINE
102 const Derived& this_() const noexcept
104 return *
static_cast<const Derived*
>(
this);
108template <
typename T,
typename Null,
typename Enable =
void>
class SbeOptional;
110template<
class T,
typename Null>
115 , typename std::enable_if
117 std::is_same<T, typename Null::Value>::value
118 && isConstant<Null>::value
119 && !isScopedEnum<T>::value
128 ,
typename std::enable_if<std::is_constructible<T, U&&>::value,
void*>::type =
nullptr>
130 : value_(std::forward<U>(u))
134 template<
class U,
class V,
class... Rest
135 ,
typename std::enable_if<std::is_constructible<T, U&&, V&&, Rest&&...>::value,
void*>::type =
nullptr>
136 explicit SbeOptional(U&& u, V&& v, Rest&&... rest)
noexcept(
noexcept(T(std::forward<U>(u), std::forward<V>(v), std::forward<Rest>(rest)...)))
137 : value_(std::forward<U>(u), std::forward<V>(v), std::forward<Rest>(rest)...)
142 : value_(Null::
value())
147 : value_(Null::value())
151 ChooseValueKind<T>
raw() const noexcept
158 return value_ != Null::value();
178template<
class T,
typename Null>
182 static_assert(isScopedEnum<T>::value,
"");
183 static_assert(std::is_same<typename underlyingType<T>::type,
typename Null::Value>
::value,
"");
194 : value_(static_cast<T>(Null::
value()))
199 : value_(
static_cast<T
>(Null::value()))
210 return toUnderlying(value_) != Null::value();
253 return !value_.empty();
282 new (
static_cast<void*
>(storage_)) T(std::forward<T&&>(
value));
295 static_assert(std::is_trivially_destructible<T>::value,
"");
317 const T* ptr() const noexcept
319 return reinterpret_cast<const T*
>(storage_);
322 alignas(T) uint8_t storage_[
sizeof(T)];
332 : std::integral_constant
335 std::is_base_of<SbeOptionalField<cleanType<T>>, cleanType<T>>::value
341typename std::enable_if<isOptional<T>::value,
bool>::type
348typename std::enable_if<isOptional<T>::value,
bool>::type
355typename std::enable_if<isOptional<T>::value,
bool>::type
362typename std::enable_if<isOptional<T>::value,
bool>::type
375typename std::enable_if<isOptional<T>::value, std::ostream&>::type
376 operator<<(std::ostream& stream,
const T& value)
378 stream <<
toStr(value);
#define ONIXS_ICEBOE_MESSAGING_NAMESPACE_BEGIN
#define ONIXS_ICEBOE_MESSAGING_NAMESPACE_END
#define ONIXS_ICEBOE_EXPORTED
bool hasValue() const noexcept
constexpr SbeOptionalConverted() noexcept
constexpr SbeOptionalConverted(NullOpt) noexcept
~SbeOptionalConverted()=default
ChooseValueKind< T > operator*() const noexcept
const T * operator->() const noexcept
SbeOptionalConverted(T &&value) noexcept
bool hasValue() const noexcept
constexpr SbeOptionalEnumeration() noexcept
SbeOptionalEnumeration(T v) noexcept
T operator*() const noexcept
constexpr SbeOptionalEnumeration(NullOpt) noexcept
~SbeOptionalField()=default
std::optional< std::decay_t< decltype(*std::declval< const D & >())> > Native
static ONIXS_ICEBOE_FORCEINLINE constexpr Derived null() noexcept
ONIXS_ICEBOE_FORCEINLINE auto value() const -> decltype(*std::declval< const D & >())
auto asNative() const noexcept
bool hasValue() const noexcept
StrRef raw() const noexcept
const StrRef * operator->() const noexcept
constexpr SbeOptionalStr(StrRef v) noexcept
constexpr SbeOptionalStr(NullOpt) noexcept
StrRef operator*() const noexcept
constexpr SbeOptionalStr() noexcept
bool hasValue() const noexcept
ChooseValueKind< T > raw() const noexcept
SbeOptional(U &&u) noexcept(noexcept(T(std::forward< U >(u))))
ChooseValueKind< T > operator*() const noexcept
const T * operator->() const noexcept
constexpr SbeOptional(NullOpt) noexcept
SbeOptional(U &&u, V &&v, Rest &&... rest) noexcept(noexcept(T(std::forward< U >(u), std::forward< V >(v), std::forward< Rest >(rest)...)))
constexpr SbeOptional() noexcept
std::ostream & operator<<(std::ostream &stream, const FloatingPointDecimal< Mantissa, Exponent > &value)
Serializes into a stream.
void throwBadOptionalAccess()
bool operator!=(const Decimal &left, const Decimal &right)
SbeOptional< typename T::Value, T > SbeOptionalT
std::string toStr(const FixedPointDecimal< Mantissa, Exponent > &)
Serializes a fixed-point decimal into a string.
@ D
Other, including other-provided screen.
std::basic_string_view< Char > StrRef
bool operator==(const Decimal &left, const Decimal &right) noexcept
constexpr OptionalTag optional