85 return std::strong_ordering::equal;
106 requires (
sizeof...(Ts) > 0)
109 static constexpr std::size_t
npos =
static_cast<std::size_t
>(-1);
135 using Alternative = std::tuple_element_t<
index, std::tuple<Ts...>>;
136 m_storage = Make<Alternative>(std::forward<T>(value));
148 template<std::size_t I,
class... Args>
159 template<
class T,
class... Args>
160 explicit Variant(std::in_place_type_t<T> tag, Args&&... args);
167 explicit Variant(
const std::variant<Ts...>& value);
174 explicit Variant(std::variant<Ts...>&& value);
243 template<
std::
size_t I, class... Args>
254 template<class T, class... Args>
285 return Visit([](
const auto& alternative) -> std::variant<Ts...> {
299 template<
class Alternative,
class... Args>
300 static Alternative* Make(Args&&... args);
315 template<
std::
size_t I, class Visitor>
316 decltype(auto) VisitIndex(Visitor&& visitor) const;
325 template<class Visitor>
326 decltype(auto) Visit(Visitor&& visitor) const;
331 template<
std::
size_t I,
Type::SafeValue... Us>
334 template<
std::
size_t I,
Type::SafeValue... Us>
337 template<class T,
Type::SafeValue... Us>
340 template<class T,
Type::SafeValue... Us>
343 template<class Visitor,
Type::SafeValue... Us>
346 template<class Visitor,
Type::SafeValue... Us>
347 friend decltype(auto)
visit(Visitor&& visitor, const
Variant<Us...>& value);
357 template<class T,
Type::SafeValue... Ts>
368 template<
std::
size_t I,
Type::SafeValue... Ts>
379 template<
std::
size_t I,
Type::SafeValue... Ts>
390 template<class T,
Type::SafeValue... Ts>
401 template<class T,
Type::SafeValue... Ts>
411 template<
std::
size_t I,
Type::SafeValue... Ts>
421 template<
std::
size_t I,
Type::SafeValue... Ts>
431 template<class T,
Type::SafeValue... Ts>
441 template<class T,
Type::SafeValue... Ts>
453 template<class Visitor,
Type::SafeValue... Ts>
465 template<class Visitor,
Type::SafeValue... Ts>
474 template<
Type::SafeValue... Ts>
493 if (value.valueless_by_exception())
495 std::size_t current = 0;
496 auto step = [&](
auto* unused) {
497 using Alternative = std::remove_pointer_t<
decltype(unused)>;
498 if (current == value.index()) {
500 if (alternative !=
nullptr)
505 (step(
static_cast<Ts*
>(
nullptr)), ...);
A variant was read with the wrong alternative, or while valueless.
Definition exception.hxx:347
std::variant stored on Base's heap.
Definition variant.hxx:107
static constexpr std::size_t npos
No alternative.
Definition variant.hxx:109
Variant()
Default-construct the first alternative.
Variant(std::in_place_index_t< I > index, Args &&... args)
Construct the alternative at I.
Variant(const Variant &other)
Copy the active alternative into a new Base block.
static constexpr std::size_t AlternativeIndex() noexcept
Index of the single alternative constructible from T, or npos.
auto & emplace(Args &&... args)
Construct the alternative at I, replacing the current one only after construction.
~Variant() noexcept
Destroy the active alternative and release its block.
bool valueless_by_exception() const noexcept
Whether a throwing operation left this variant without an alternative.
void swap(Variant &other) noexcept
Exchange storage.
Variant(std::in_place_type_t< T > tag, Args &&... args)
Construct the alternative T.
std::size_t index() const noexcept
Index of the active alternative, or npos when valueless.
Variant(std::variant< Ts... > &&value)
Move a caller-owned std::variant by copying the alternative into Base storage.
Variant(const std::variant< Ts... > &value)
Copy a caller-owned std::variant.
Variant(Variant &&other) noexcept
Take the active block.
friend decltype(auto) visit(Visitor &&visitor, Variant< Us... > &value)
friend auto * get_if(Variant< Us... > *value) noexcept
Value permitted in opaque Safe collections.
Definition safe.hxx:409
Instantiation of std::variant, after stripping cv and references.
Definition wrappers.hxx:177
Private Base heap used by StormByte::Safe::Shared, StormByte::Safe::Unique and StormByte::Safe::Clona...
Owned values that cross a DLL without the caller's CRT.
bool holds_alternative(const Variant< Ts... > &value) noexcept
Whether value holds T.
STORMBYTE_FORCE_INLINE std::size_t HashCombine(std::size_t seed, std::size_t next) noexcept
Mix an existing hash with another.
Definition hash.hxx:83
auto * get_if(Variant< Ts... > *value) noexcept
Pointer to the alternative at I, or null.
constexpr First & get(Pair< First, Second > &pair) noexcept
Access the first pair member.
void swap(Binary &left, Binary &right) noexcept
Exchange two sequences.
Definition binary.hxx:760
decltype(auto) visit(Visitor &&visitor, Variant< Ts... > &value)
Call visitor with the active alternative.
@ Release
Release.
Definition memory_order.hxx:64
STORMBYTE_FORCE_INLINE std::size_t HashBytes(std::span< const std::byte > bytes) noexcept
Mix a byte range with FNV-1a.
Definition hash.hxx:66
Root namespace of the StormByte suite.
Octet count. Defined in byte_size.hxx. Forwarded so Type::Numeral can name it.
STORMBYTE_FORCE_INLINE std::size_t operator()(StormByte::Safe::Monostate) const noexcept
Hash an empty alternative.
Definition variant.hxx:516
STORMBYTE_FORCE_INLINE std::size_t operator()(const StormByte::Safe::Variant< Ts... > &value) const noexcept
Hash the index and the active alternative.
Definition variant.hxx:491
Cross-module hash.
Definition hash.hxx:95
Empty alternative.
Definition variant.hxx:71
friend constexpr bool operator==(Monostate, Monostate) noexcept
Two empty alternatives are equal.
Definition variant.hxx:76
friend STORMBYTE_FORCE_INLINE constexpr std::strong_ordering operator<=>(Monostate, Monostate) noexcept
Two empty alternatives compare equal.
Definition variant.hxx:84
Recognizes collection values with Base-controlled lifetime.
Definition safe.hxx:347
Recognizes Base Safe components, not universal ABI compatibility.
Definition safe.hxx:138
std::size_t operator()(StormByte::Safe::Monostate value) const noexcept
Hashes an empty alternative.
Definition variant.hxx:539
std::size_t operator()(const StormByte::Safe::Variant< Ts... > &value) const noexcept
Hashes value.
Definition variant.hxx:528
#define STORMBYTE_PUBLIC_TYPE
Definition visibility.h:57