StormByte 3.0.0
C++26 foundation of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Safe Namespace Reference

Owned values that cross a DLL without the caller's CRT. More...

Namespaces

namespace  Detail
 Private helpers.
namespace  Heap
 Allocate and free raw blocks on Base's heap.
namespace  this_thread
 Operations on the calling execution.

Classes

struct  Hash< StormByte::ByteSize >
class  Atomic
 Atomic word of one, two, four or eight bytes. More...
class  Binary
 Owned contiguous sequence of std::byte, stored in a Vector. More...
struct  Hash< StormByte::Safe::Binary >
 Cross-module hash of the byte sequence. More...
class  Callback
 Callback with explicitly cloned context and creator-module release. More...
class  Clonable
 Polymorphic copy and move through a base. More...
class  ConditionVariable
 Wakes threads waiting on a Mutex. More...
class  ConditionVariableAny
 Wakes a thread that waits with any lock it can drop and retake. More...
class  Deque
 Double-ended sequence stored on Base's heap. More...
class  Exception
 Base exception for Safe. More...
class  AllocationError
 Memory allocation failed under Safe. More...
class  ExpiredWeakPointerError
 A shared owner cannot be obtained from an empty or expired observer. More...
class  OutOfBoundsError
 An index or range is out of bounds. More...
class  BadOptionalAccess
 An empty Optional was dereferenced. More...
class  BadVariantAccess
 A variant was read with the wrong alternative, or while valueless. More...
class  ExclusiveLock
 Owns at most one exclusive hold of a SharedMutex. More...
class  Function
 Copyable, creator-context callback with a typed signature. More...
class  Function< void(Args...)>
 Typed callback specialization for void-returning signatures. More...
class  Function< Return(Args...)>
 Typed callback specialization for value-returning signatures. More...
class  Hash
 Cross-module hash. More...
struct  Hash< T >
 Hash of an integral or enumeration value. More...
struct  Hash< T * >
 Hash of a pointer identity. More...
class  Iterable
 Gives a Safe component the iterators of its category. More...
class  List
 Doubly linked list stored on Base's heap. More...
class  Map
 Ordered unique-key map stored on Base's heap. More...
struct  DeferLock
 Do not lock the mutex in the UniqueLock constructor. More...
struct  TryToLock
 Try to lock the mutex in the UniqueLock constructor. More...
struct  AdoptLock
 The calling thread already owns the mutex. More...
class  Mutex
 Non-recursive mutex. More...
class  Optional
 std::optional stored on Base's heap. More...
struct  Hash< StormByte::Safe::Optional< T > >
 Cross-module hash of a StormByte::Safe::Optional. More...
class  Pair
 std::pair whose members keep their own Safe storage. More...
class  PairReference
 Tuple-like proxy for an immutable first value and callback-backed second value. More...
struct  Hash< StormByte::Safe::Pair< First, Second > >
 Cross-module hash of a StormByte::Safe::Pair. More...
class  Shared
 Forward declaration of shared ownership. More...
class  Unique
 Forward declaration of unique ownership. More...
class  Weak
 Forward declaration of weak ownership. More...
class  AtomicShared
 Atomic publication of a Shared. More...
class  EnableSharedFromThis
 Base that can recover a Shared from an object owned by one. More...
struct  Hash< StormByte::Safe::Shared< T > >
struct  Hash< StormByte::Safe::Unique< T > >
struct  Hash< StormByte::Safe::Weak< T > >
class  Queue
 FIFO sequence stored on Base's heap. More...
struct  ReplaceTokenSpec
 One ReplaceToken field. More...
struct  ReplaceTokenPlace
 Where a field sits in the pattern, and how to render its argument. More...
class  SecureBinary
 Binary for secrets: every byte it drops or releases is zeroed first. More...
class  Set
 Ordered unique values stored on Base's heap. More...
class  SharedLock
 Owns at most one shared hold of a SharedMutex. More...
class  SharedMutex
 Non-recursive shared mutex. More...
class  String
 Owned UTF-8 text. More...
struct  Hash< StormByte::Safe::String >
class  Thread
 Execution owned by Base. More...
class  UniqueLock
 Owns at most one Mutex. More...
class  UnorderedMap
 Unique-key hash map stored on Base's heap. More...
class  UnorderedSet
 Unique values stored in a Base-heap hash table. More...
struct  Monostate
 Empty alternative. More...
class  Variant
 std::variant stored on Base's heap. More...
struct  Hash< StormByte::Safe::Variant< Ts... > >
struct  Hash< StormByte::Safe::Monostate >
class  Vector
 Contiguous sequence stored on Base's heap. More...
class  WString
 Wide counterpart of String. More...
struct  Hash< StormByte::Safe::WString >
struct  Hash< StormByte::Size >

Concepts

concept  ValidSmartPointer
 true when SmartPointer is StormByte::Safe::Shared<T> or StormByte::Safe::Unique<T>.
concept  ReplaceTokenBuiltin
 True when FormatReplaceToken always writes T and never asks for a string conversion.

Typedefs

using Owner = Detail::Owner
 Public name for opaque state ownership through provider callbacks.

Enumerations

enum class  MemoryOrder : unsigned char {
  Relaxed , Consume , Acquire , Release ,
  AcqRel , SeqCst
}
 Ordering for a Atomic operation. More...
enum class  CvStatus : unsigned char { NoTimeout , Timeout }
 Why a timed wait returned. More...
enum class  Status : unsigned char { Success , Missing , Failure }
 Result of a collection operation; exceptions never leave its owner callback. More...

Functions

void swap (Binary &left, Binary &right) noexcept
 Exchange two sequences.
bool operator== (std::span< const std::byte > bytes, const Binary &data) noexcept
 Equality of a span against a sequence.
bool operator!= (std::span< const std::byte > bytes, const Binary &data) noexcept
 Inequality of a span against a sequence.
STORMBYTE_FORCE_INLINE std::strong_ordering operator<=> (std::span< const std::byte > bytes, const Binary &data) noexcept
 Three-way comparison of a span against a sequence.
void ThrowDequeOutOfBounds ()
 Throw the deque out-of-bounds error from Base.
void ThrowDequeOutOfBounds (const Size &index)
template<Type::SafeValue T>
bool operator== (const Deque< T > &left, const Deque< T > &right)
 Whether two deques contain equal elements.
template<Type::SafeValue T>
STORMBYTE_FORCE_INLINE std::strong_ordering operator<=> (const Deque< T > &left, const Deque< T > &right)
 Order two deques lexicographically.
template<Type::SafeValue T>
void swap (Deque< T > &left, Deque< T > &right) noexcept
 Exchange two deques.
void swap (ExclusiveLock &left, ExclusiveLock &right) noexcept
 Exchange two exclusive locks.
STORMBYTE_FORCE_INLINE std::size_t HashBytes (std::span< const std::byte > bytes) noexcept
 Mix a byte range with FNV-1a.
STORMBYTE_FORCE_INLINE std::size_t HashCombine (std::size_t seed, std::size_t next) noexcept
 Mix an existing hash with another.
template<Type::SafeValue T>
void swap (List< T > &left, List< T > &right) noexcept
 Exchange two lists.
template<Type::SafeValue K, Type::SafeValue V, class Compare>
void swap (Map< K, V, Compare > &left, Map< K, V, Compare > &right) noexcept
 Exchange two maps.
template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 0)
constexpr First & get (Pair< First, Second > &pair) noexcept
 Access the first pair member.
template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 1)
constexpr Second & get (Pair< First, Second > &pair) noexcept
 Access the second pair member.
template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 0)
constexpr const First & get (const Pair< First, Second > &pair) noexcept
 Access the first pair member through a const pair.
template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 1)
constexpr const Second & get (const Pair< First, Second > &pair) noexcept
 Access the second pair member through a const pair.
template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 0)
constexpr First && get (Pair< First, Second > &&pair) noexcept
 Move-access the first pair member.
template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 1)
constexpr Second && get (Pair< First, Second > &&pair) noexcept
 Move-access the second pair member.
template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 0)
constexpr const First && get (const Pair< First, Second > &&pair) noexcept
 Read the first member from a const rvalue pair.
template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 1)
constexpr const Second && get (const Pair< First, Second > &&pair) noexcept
 Read the second member from a const rvalue pair.
template<class T, class... Args>
Shared< T > MakeShared (Args &&... args)
 Construct T on Base's heap and share it.
template<class T, class... Args>
Unique< T > MakeUnique (Args &&... args)
 Construct T on Base's heap and own it.
template<class T, class U>
Shared< T > StaticPointerCast (const Shared< U > &from) noexcept
 static_cast of the stored pointer.
template<class T, class U>
Shared< T > DynamicPointerCast (const Shared< U > &from) noexcept
 dynamic_cast of the stored pointer.
template<class T, class U>
Shared< T > ConstPointerCast (const Shared< U > &from) noexcept
 const_cast of the stored pointer.
template<class T, class U>
Shared< T > ReinterpretPointerCast (const Shared< U > &from) noexcept
 reinterpret_cast of the stored pointer.
template<class T, class U>
STORMBYTE_FORCE_INLINE bool operator== (const Shared< T > &left, const Shared< U > &right) noexcept
 Same stored pointer.
template<class T, class U>
STORMBYTE_FORCE_INLINE std::strong_ordering operator<=> (const Shared< T > &left, const Shared< U > &right) noexcept
 Order of the stored pointers.
template<class T>
STORMBYTE_FORCE_INLINE bool operator== (const Shared< T > &left, std::nullptr_t null) noexcept
 Compare an owner with null.
template<class T>
STORMBYTE_FORCE_INLINE std::strong_ordering operator<=> (const Shared< T > &left, std::nullptr_t null) noexcept
 Order an owner against null.
template<class T, class U>
STORMBYTE_FORCE_INLINE bool operator== (const Unique< T > &left, const Unique< U > &right) noexcept
 Same stored pointer.
template<class T, class U>
STORMBYTE_FORCE_INLINE std::strong_ordering operator<=> (const Unique< T > &left, const Unique< U > &right) noexcept
 Order of the stored pointers.
template<class T>
STORMBYTE_FORCE_INLINE bool operator== (const Unique< T > &left, std::nullptr_t null) noexcept
 Compare an owner with null.
template<class T>
STORMBYTE_FORCE_INLINE std::strong_ordering operator<=> (const Unique< T > &left, std::nullptr_t null) noexcept
 Order an owner against null.
template<class T>
void swap (Shared< T > &left, Shared< T > &right) noexcept
 Exchange two owners.
template<class T>
void swap (Unique< T > &left, Unique< T > &right) noexcept
 Exchange two owners.
template<class T>
void swap (Weak< T > &left, Weak< T > &right) noexcept
 Exchange two observers.
void ThrowQueueOutOfBounds ()
 Throw the queue out-of-bounds error from Base.
template<Type::SafeValue T>
void swap (Queue< T > &left, Queue< T > &right) noexcept
 Exchange two queues.
template<class Char>
constexpr bool ParseReplaceTokenSpec (const Char *data, std::size_t count, ReplaceTokenSpec &out) noexcept
 Parse the inside of one {...}.
template<class Char>
std::size_t FindReplaceTokens (std::basic_string_view< Char > text, ReplaceTokenPlace< Char > *places, std::size_t capacity) noexcept
 Collect up to capacity fields, in order.
template<class Char, class T>
bool FormatReplaceToken (std::basic_string< Char > &out, T &&value, const ReplaceTokenSpec &spec)
 Render one argument when it does not need an owned-string conversion.
template<Type::SafeValue K, class Compare>
void swap (Set< K, Compare > &left, Set< K, Compare > &right) noexcept
 Exchange two sets.
void swap (SharedLock &left, SharedLock &right) noexcept
 Exchange two shared locks.
STORMBYTE_FORCE_INLINE std::ostream & operator<< (std::ostream &stream, const String &text)
 Writes text to stream.
bool operator== (const char *str, const String &text) noexcept
 Content equality.
bool operator!= (const char *str, const String &text) noexcept
 Content inequality.
String operator+ (const String &left, const String &right)
 Concatenate two texts.
void swap (String &left, String &right) noexcept
 Swaps two texts.
void swap (Thread &left, Thread &right) noexcept
 Exchange two executions.
void swap (UniqueLock &left, UniqueLock &right) noexcept
 Exchange two locks.
template<Type::SafeValue K, Type::SafeValue V, class Hash, class KeyEqual>
void swap (UnorderedMap< K, V, Hash, KeyEqual > &left, UnorderedMap< K, V, Hash, KeyEqual > &right) noexcept
 Exchange two maps.
template<Type::SafeValue K, class Hash, class KeyEqual>
void swap (UnorderedSet< K, Hash, KeyEqual > &left, UnorderedSet< K, Hash, KeyEqual > &right) noexcept
 Exchange two sets.
template<class T, Type::SafeValue... Ts>
bool holds_alternative (const Variant< Ts... > &value) noexcept
 Whether value holds T.
template<std::size_t I, Type::SafeValue... Ts>
auto & get (Variant< Ts... > &value)
 Read the alternative at I.
template<std::size_t I, Type::SafeValue... Ts>
const auto & get (const Variant< Ts... > &value)
 Read the alternative at I.
template<class T, Type::SafeValue... Ts>
T & get (Variant< Ts... > &value)
 Read the alternative T.
template<class T, Type::SafeValue... Ts>
const T & get (const Variant< Ts... > &value)
 Read the alternative T.
template<std::size_t I, Type::SafeValue... Ts>
auto * get_if (Variant< Ts... > *value) noexcept
 Pointer to the alternative at I, or null.
template<std::size_t I, Type::SafeValue... Ts>
const auto * get_if (const Variant< Ts... > *value) noexcept
 Pointer to the alternative at I, or null.
template<class T, Type::SafeValue... Ts>
T * get_if (Variant< Ts... > *value) noexcept
 Pointer to the alternative T, or null.
template<class T, Type::SafeValue... Ts>
const T * get_if (const Variant< Ts... > *value) noexcept
 Pointer to the alternative T, or null.
template<class Visitor, Type::SafeValue... Ts>
decltype(auto) visit (Visitor &&visitor, Variant< Ts... > &value)
 Call visitor with the active alternative.
template<class Visitor, Type::SafeValue... Ts>
decltype(auto) visit (Visitor &&visitor, const Variant< Ts... > &value)
 Call visitor with the active alternative.
template<Type::SafeValue... Ts>
void swap (Variant< Ts... > &left, Variant< Ts... > &right) noexcept
 Swaps two variants.
void ThrowVectorOutOfBounds ()
 Throw the vector out-of-bounds error from Base.
void ThrowVectorOutOfBounds (const Size &index)
template<Type::SafeValue T>
void swap (Vector< T > &lhs, Vector< T > &rhs) noexcept
 Exchange two sequences.
STORMBYTE_FORCE_INLINE std::wostream & operator<< (std::wostream &stream, const WString &text)
 Writes text to stream.
bool operator== (const wchar_t *str, const WString &text) noexcept
 Content equality.
bool operator!= (const wchar_t *str, const WString &text) noexcept
 Content inequality.
WString operator+ (const WString &left, const WString &right)
 Concatenate two texts.
void swap (WString &left, WString &right) noexcept
 Swaps two texts.

Variables

constexpr DeferLock defer_lock {}
 Tag value for DeferLock.
constexpr TryToLock try_to_lock {}
 Tag value for TryToLock.
constexpr AdoptLock adopt_lock {}
 Tag value for AdoptLock.

Detailed Description

Owned values that cross a DLL without the caller's CRT.

Unit count. Defined in size.hxx. Forwarded so Type::Sized can name it.

Owned UTF-8 and wide text.

Types that are safe to pass across a DLL boundary: owners and polymorphic clones on Base's heap.

Types safe to pass across a DLL boundary.

Short UTF-8 lives in the object; the long path is Base-owned SDS.

Short wide text lives in the object; the long path is Base-owned.

Suite text types owned by Base.

Typedef Documentation

◆ Owner

Public name for opaque state ownership through provider callbacks.

Copy invokes the provider's Clone callback; destruction invokes its Destroy callback. This is conditionally DLL-safe only when the state and callbacks meet the documented MaybeSafe requirements and the provider module remains loaded for every live owner.

Enumeration Type Documentation

◆ CvStatus

enum class StormByte::Safe::CvStatus : unsigned char
strong

Why a timed wait returned.

Enumerator
NoTimeout 

Notified, or a spurious wake.

Timeout 

The deadline passed.

◆ MemoryOrder

enum class StormByte::Safe::MemoryOrder : unsigned char
strong

Ordering for a Atomic operation.

Same meaning as the standard orders. Not an alias of std::memory_order.

Enumerator
Relaxed 

No inter-thread ordering.

Consume 

Consume. The implementation promotes it to acquire.

Acquire 

Acquire.

Release 

Release.

AcqRel 

Acquire plus release.

SeqCst 

Sequentially consistent.

◆ Status

enum class StormByte::Safe::Status : unsigned char
strong

Result of a collection operation; exceptions never leave its owner callback.

Enumerator
Success 

Operation completed.

Missing 

Index or key is absent.

Failure 

Allocation, copying or comparison failed; no exception crosses the callback.

Function Documentation

◆ ConstPointerCast()

template<class T, class U>
Shared< T > StormByte::Safe::ConstPointerCast ( const Shared< U > & from)
noexcept

const_cast of the stored pointer.

The control block stays.

Template Parameters
TTarget pointee.
USource pointee.
Parameters
fromOwner.
Returns
Owner of the cast pointer.

◆ DynamicPointerCast()

template<class T, class U>
Shared< T > StormByte::Safe::DynamicPointerCast ( const Shared< U > & from)
noexcept

dynamic_cast of the stored pointer.

Empty when the cast fails.

Template Parameters
TTarget pointee.
USource pointee.
Parameters
fromOwner.
Returns
Owner of the cast pointer, or empty.

◆ FindReplaceTokens()

template<class Char>
std::size_t StormByte::Safe::FindReplaceTokens ( std::basic_string_view< Char > text,
ReplaceTokenPlace< Char > * places,
std::size_t capacity )
noexcept

Collect up to capacity fields, in order.

Template Parameters
Charchar or wchar_t.
Parameters
textPattern.
placesOutput. Only the first returned count is written.
capacitySlots available.
Returns
How many fields were stored. A brace run that is not a supported spec stays literal.

◆ FormatReplaceToken()

template<class Char, class T>
bool StormByte::Safe::FormatReplaceToken ( std::basic_string< Char > & out,
T && value,
const ReplaceTokenSpec & spec )

Render one argument when it does not need an owned-string conversion.

Template Parameters
Charchar or wchar_t.
TArgument type, including references.
Parameters
outCaller scratch. Replaced when this returns true.
valueArgument. A view is copied into out. A pointer is not dereferenced.
specField spec. A default spec keeps the historical conversion.
Returns
False when the caller must convert value through std::string / String or the wide equivalents.

◆ get() [1/12]

template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 1)
const Second && StormByte::Safe::get ( const Pair< First, Second > && pair)
constexprnoexcept

Read the second member from a const rvalue pair.

Template Parameters
IndexMember index, which must be one.
Parameters
pairPair to access.
Returns
Const rvalue reference to the second member.

◆ get() [2/12]

template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 0)
const First && StormByte::Safe::get ( const Pair< First, Second > && pair)
constexprnoexcept

Read the first member from a const rvalue pair.

Template Parameters
IndexMember index, which must be zero.
Parameters
pairPair to access.
Returns
Const rvalue reference to the first member.

◆ get() [3/12]

template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 1)
const Second & StormByte::Safe::get ( const Pair< First, Second > & pair)
constexprnoexcept

Access the second pair member through a const pair.

Template Parameters
IndexMember index, which must be one.
Parameters
pairPair to access.
Returns
Const second member reference.

◆ get() [4/12]

template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 0)
const First & StormByte::Safe::get ( const Pair< First, Second > & pair)
constexprnoexcept

Access the first pair member through a const pair.

Template Parameters
IndexMember index, which must be zero.
Parameters
pairPair to access.
Returns
Const first member reference.

◆ get() [5/12]

template<class T, Type::SafeValue... Ts>
const T & StormByte::Safe::get ( const Variant< Ts... > & value)

Read the alternative T.

Template Parameters
TAlternative. It occurs once.
TsAlternatives.
Parameters
valueVariant.
Returns
Alternative.
Exceptions
BadVariantAccessT is not active.

◆ get() [6/12]

template<std::size_t I, Type::SafeValue... Ts>
const auto & StormByte::Safe::get ( const Variant< Ts... > & value)

Read the alternative at I.

Template Parameters
IAlternative index.
TsAlternatives.
Parameters
valueVariant.
Returns
Alternative.
Exceptions
BadVariantAccessThe index is not active.

◆ get() [7/12]

template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 1)
Second && StormByte::Safe::get ( Pair< First, Second > && pair)
constexprnoexcept

Move-access the second pair member.

Template Parameters
IndexMember index, which must be one.
Parameters
pairPair to access.
Returns
Rvalue reference to the second member.

◆ get() [8/12]

template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 0)
First && StormByte::Safe::get ( Pair< First, Second > && pair)
constexprnoexcept

Move-access the first pair member.

Template Parameters
IndexMember index, which must be zero.
Parameters
pairPair to access.
Returns
Rvalue reference to the first member.

◆ get() [9/12]

template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 1)
Second & StormByte::Safe::get ( Pair< First, Second > & pair)
constexprnoexcept

Access the second pair member.

Template Parameters
IndexMember index, which must be one.
Parameters
pairPair to access.
Returns
Second member reference.

◆ get() [10/12]

template<std::size_t Index, Type::SafeValue First, Type::SafeValue Second>
requires (Index == 0)
First & StormByte::Safe::get ( Pair< First, Second > & pair)
constexprnoexcept

Access the first pair member.

Template Parameters
IndexMember index, which must be zero.
Parameters
pairPair to access.
Returns
First member reference.

◆ get() [11/12]

template<class T, Type::SafeValue... Ts>
T & StormByte::Safe::get ( Variant< Ts... > & value)

Read the alternative T.

Template Parameters
TAlternative. It occurs once.
TsAlternatives.
Parameters
valueVariant.
Returns
Alternative.
Exceptions
BadVariantAccessT is not active.

◆ get() [12/12]

template<std::size_t I, Type::SafeValue... Ts>
auto & StormByte::Safe::get ( Variant< Ts... > & value)

Read the alternative at I.

Template Parameters
IAlternative index.
TsAlternatives.
Parameters
valueVariant.
Returns
Alternative.
Exceptions
BadVariantAccessThe index is not active.

◆ get_if() [1/4]

template<class T, Type::SafeValue... Ts>
const T * StormByte::Safe::get_if ( const Variant< Ts... > * value)
noexcept

Pointer to the alternative T, or null.

Template Parameters
TAlternative. It occurs once.
TsAlternatives.
Parameters
valueVariant.
Returns
Pointer, or null when T is not active.

◆ get_if() [2/4]

template<std::size_t I, Type::SafeValue... Ts>
const auto * StormByte::Safe::get_if ( const Variant< Ts... > * value)
noexcept

Pointer to the alternative at I, or null.

Template Parameters
IAlternative index.
TsAlternatives.
Parameters
valueVariant.
Returns
Pointer, or null when the index is not active.

◆ get_if() [3/4]

template<class T, Type::SafeValue... Ts>
T * StormByte::Safe::get_if ( Variant< Ts... > * value)
noexcept

Pointer to the alternative T, or null.

Template Parameters
TAlternative. It occurs once.
TsAlternatives.
Parameters
valueVariant.
Returns
Pointer, or null when T is not active.

◆ get_if() [4/4]

template<std::size_t I, Type::SafeValue... Ts>
auto * StormByte::Safe::get_if ( Variant< Ts... > * value)
noexcept

Pointer to the alternative at I, or null.

Template Parameters
IAlternative index.
TsAlternatives.
Parameters
valueVariant.
Returns
Pointer, or null when the index is not active.

◆ HashBytes()

STORMBYTE_FORCE_INLINE std::size_t StormByte::Safe::HashBytes ( std::span< const std::byte > bytes)
noexcept

Mix a byte range with FNV-1a.

Empty is a defined value.

Parameters
bytesBytes. May be empty.
Returns
Hash. The same bytes produce the same value in every module.

◆ HashCombine()

STORMBYTE_FORCE_INLINE std::size_t StormByte::Safe::HashCombine ( std::size_t seed,
std::size_t next )
noexcept

Mix an existing hash with another.

Order matters.

Parameters
seedHash so far.
nextNext hash.
Returns
Combined hash.

◆ holds_alternative()

template<class T, Type::SafeValue... Ts>
bool StormByte::Safe::holds_alternative ( const Variant< Ts... > & value)
noexcept

Whether value holds T.

Template Parameters
TAlternative.
TsAlternatives.
Parameters
valueVariant.
Returns
Match. A valueless variant does not hold T.

◆ MakeShared()

template<class T, class... Args>
Shared< T > StormByte::Safe::MakeShared ( Args &&... args)

Construct T on Base's heap and share it.

Template Parameters
TObject type.
ArgsConstructor argument types.
Parameters
argsArguments forwarded to T.
Returns
Owning Shared.
Exceptions
AllocationErrorThe block could not be allocated.

◆ MakeUnique()

template<class T, class... Args>
Unique< T > StormByte::Safe::MakeUnique ( Args &&... args)

Construct T on Base's heap and own it.

Template Parameters
TObject type.
ArgsConstructor argument types.
Parameters
argsArguments forwarded to T.
Returns
Owning Unique.
Exceptions
AllocationErrorThe block could not be allocated.

◆ operator!=() [1/3]

bool StormByte::Safe::operator!= ( const char * str,
const String & text )
inlinenoexcept

Content inequality.

Parameters
strC string; may be null.
textText.
Returns
Whether the texts differ.

◆ operator!=() [2/3]

bool StormByte::Safe::operator!= ( const wchar_t * str,
const WString & text )
inlinenoexcept

Content inequality.

Parameters
strWide C string; may be null.
textText.
Returns
Whether the texts differ.

◆ operator!=() [3/3]

bool StormByte::Safe::operator!= ( std::span< const std::byte > bytes,
const Binary & data )
inlinenoexcept

Inequality of a span against a sequence.

Parameters
bytesLeft view.
dataRight sequence.
Returns
Same as data != bytes.

◆ operator+() [1/2]

String StormByte::Safe::operator+ ( const String & left,
const String & right )
inline

Concatenate two texts.

A literal or a view converts to String.

Parameters
leftLeft text.
rightRight text.
Returns
New text owned by Base.
Exceptions
AllocationErrorThe long path could not be allocated.

◆ operator+() [2/2]

WString StormByte::Safe::operator+ ( const WString & left,
const WString & right )
inline

Concatenate two texts.

A literal or a view converts to WString.

Parameters
leftLeft text.
rightRight text.
Returns
New text owned by Base.
Exceptions
AllocationErrorThe long path could not be allocated.

◆ operator<<() [1/2]

STORMBYTE_FORCE_INLINE std::ostream & StormByte::Safe::operator<< ( std::ostream & stream,
const String & text )

Writes text to stream.

Parameters
streamDestination. Caller-owned stream.
textSource.
Returns
stream.

◆ operator<<() [2/2]

STORMBYTE_FORCE_INLINE std::wostream & StormByte::Safe::operator<< ( std::wostream & stream,
const WString & text )

Writes text to stream.

Instantiated in the caller.

Parameters
streamDestination. Caller-owned stream.
textSource.
Returns
stream.

◆ operator<=>() [1/6]

template<Type::SafeValue T>
STORMBYTE_FORCE_INLINE std::strong_ordering StormByte::Safe::operator<=> ( const Deque< T > & left,
const Deque< T > & right )

Order two deques lexicographically.

Template Parameters
TElement.
Parameters
leftLeft deque.
rightRight deque.
Returns
Ordering of the elements.

◆ operator<=>() [2/6]

template<class T, class U>
STORMBYTE_FORCE_INLINE std::strong_ordering StormByte::Safe::operator<=> ( const Shared< T > & left,
const Shared< U > & right )
noexcept

Order of the stored pointers.

Template Parameters
TLeft pointee.
URight pointee.
Parameters
leftOwner.
rightOwner.
Returns
Three-way comparison of the addresses.

◆ operator<=>() [3/6]

template<class T>
STORMBYTE_FORCE_INLINE std::strong_ordering StormByte::Safe::operator<=> ( const Shared< T > & left,
std::nullptr_t null )
noexcept

Order an owner against null.

Template Parameters
TPointee.
Parameters
leftOwner.
nullNull pointer constant.
Returns
Three-way comparison of the stored pointer and null.

◆ operator<=>() [4/6]

template<class T, class U>
STORMBYTE_FORCE_INLINE std::strong_ordering StormByte::Safe::operator<=> ( const Unique< T > & left,
const Unique< U > & right )
noexcept

Order of the stored pointers.

Template Parameters
TLeft pointee.
URight pointee.
Parameters
leftOwner.
rightOwner.
Returns
Three-way comparison of the addresses.

◆ operator<=>() [5/6]

template<class T>
STORMBYTE_FORCE_INLINE std::strong_ordering StormByte::Safe::operator<=> ( const Unique< T > & left,
std::nullptr_t null )
noexcept

Order an owner against null.

Template Parameters
TPointee.
Parameters
leftOwner.
nullNull pointer constant.
Returns
Three-way comparison of the stored pointer and null.

◆ operator<=>() [6/6]

STORMBYTE_FORCE_INLINE std::strong_ordering StormByte::Safe::operator<=> ( std::span< const std::byte > bytes,
const Binary & data )
noexcept

Three-way comparison of a span against a sequence.

Parameters
bytesLeft view.
dataRight sequence.
Returns
Reverse of data <=> bytes.

◆ operator==() [1/8]

bool StormByte::Safe::operator== ( const char * str,
const String & text )
inlinenoexcept

Content equality.

Parameters
strC string; may be null.
textText.
Returns
Whether the texts are equal.

◆ operator==() [2/8]

template<Type::SafeValue T>
bool StormByte::Safe::operator== ( const Deque< T > & left,
const Deque< T > & right )

Whether two deques contain equal elements.

Template Parameters
TElement.
Parameters
leftLeft deque.
rightRight deque.
Returns
Whether the elements compare equal.

◆ operator==() [3/8]

template<class T, class U>
STORMBYTE_FORCE_INLINE bool StormByte::Safe::operator== ( const Shared< T > & left,
const Shared< U > & right )
noexcept

Same stored pointer.

Template Parameters
TLeft pointee.
URight pointee.
Parameters
leftOwner.
rightOwner.
Returns
Whether both hold the same address.

◆ operator==() [4/8]

template<class T>
STORMBYTE_FORCE_INLINE bool StormByte::Safe::operator== ( const Shared< T > & left,
std::nullptr_t null )
noexcept

Compare an owner with null.

Template Parameters
TPointee.
Parameters
leftOwner.
nullNull pointer constant.
Returns
Whether left is empty.

◆ operator==() [5/8]

template<class T, class U>
STORMBYTE_FORCE_INLINE bool StormByte::Safe::operator== ( const Unique< T > & left,
const Unique< U > & right )
noexcept

Same stored pointer.

Template Parameters
TLeft pointee.
URight pointee.
Parameters
leftOwner.
rightOwner.
Returns
Whether both hold the same address.

◆ operator==() [6/8]

template<class T>
STORMBYTE_FORCE_INLINE bool StormByte::Safe::operator== ( const Unique< T > & left,
std::nullptr_t null )
noexcept

Compare an owner with null.

Template Parameters
TPointee.
Parameters
leftOwner.
nullNull pointer constant.
Returns
Whether left is empty.

◆ operator==() [7/8]

bool StormByte::Safe::operator== ( const wchar_t * str,
const WString & text )
inlinenoexcept

Content equality.

Parameters
strWide C string; may be null.
textText.
Returns
Whether the texts are equal.

◆ operator==() [8/8]

bool StormByte::Safe::operator== ( std::span< const std::byte > bytes,
const Binary & data )
inlinenoexcept

Equality of a span against a sequence.

Parameters
bytesLeft view.
dataRight sequence.
Returns
Same as data == bytes.

◆ ParseReplaceTokenSpec()

template<class Char>
bool StormByte::Safe::ParseReplaceTokenSpec ( const Char * data,
std::size_t count,
ReplaceTokenSpec & out )
constexprnoexcept

Parse the inside of one {...}.

Template Parameters
Charchar or wchar_t.
Parameters
dataSpec text, without the braces.
countNumber of code units.
outParsed spec. Untouched when this returns false.
Returns
Whether data is empty or a supported spec.

◆ ReinterpretPointerCast()

template<class T, class U>
Shared< T > StormByte::Safe::ReinterpretPointerCast ( const Shared< U > & from)
noexcept

reinterpret_cast of the stored pointer.

The control block stays.

Template Parameters
TTarget pointee.
USource pointee.
Parameters
fromOwner.
Returns
Owner of the cast pointer.

◆ StaticPointerCast()

template<class T, class U>
Shared< T > StormByte::Safe::StaticPointerCast ( const Shared< U > & from)
noexcept

static_cast of the stored pointer.

The control block stays.

Template Parameters
TTarget pointee.
USource pointee.
Parameters
fromOwner.
Returns
Owner of the cast pointer.

◆ swap() [1/19]

void StormByte::Safe::swap ( Binary & left,
Binary & right )
inlinenoexcept

Exchange two sequences.

Parameters
leftFirst sequence.
rightSecond sequence.

◆ swap() [2/19]

template<Type::SafeValue T>
void StormByte::Safe::swap ( Deque< T > & left,
Deque< T > & right )
noexcept

Exchange two deques.

Template Parameters
TElement.
Parameters
leftLeft deque.
rightRight deque.

◆ swap() [3/19]

void StormByte::Safe::swap ( ExclusiveLock & left,
ExclusiveLock & right )
inlinenoexcept

Exchange two exclusive locks.

Parameters
leftFirst lock.
rightSecond lock.

◆ swap() [4/19]

template<Type::SafeValue T>
void StormByte::Safe::swap ( List< T > & left,
List< T > & right )
noexcept

Exchange two lists.

Template Parameters
TSafe value.
Parameters
leftFirst list.
rightSecond list.

◆ swap() [5/19]

template<Type::SafeValue K, Type::SafeValue V, class Compare>
void StormByte::Safe::swap ( Map< K, V, Compare > & left,
Map< K, V, Compare > & right )
inlinenoexcept

Exchange two maps.

Does not allocate.

Template Parameters
KSafe key.
VSafe mapped type.
CompareKey ordering.
Parameters
leftFirst map.
rightSecond map.

◆ swap() [6/19]

template<Type::SafeValue T>
void StormByte::Safe::swap ( Queue< T > & left,
Queue< T > & right )
inlinenoexcept

Exchange two queues.

Does not allocate.

Template Parameters
TSafe value.
Parameters
leftFirst queue.
rightSecond queue.

◆ swap() [7/19]

template<Type::SafeValue K, class Compare>
void StormByte::Safe::swap ( Set< K, Compare > & left,
Set< K, Compare > & right )
inlinenoexcept

Exchange two sets.

Template Parameters
KValue type.
CompareOrdering.
Parameters
leftLeft set.
rightRight set.

◆ swap() [8/19]

template<class T>
void StormByte::Safe::swap ( Shared< T > & left,
Shared< T > & right )
noexcept

Exchange two owners.

Template Parameters
TPointee.
Parameters
leftOwner.
rightOwner.

◆ swap() [9/19]

void StormByte::Safe::swap ( SharedLock & left,
SharedLock & right )
inlinenoexcept

Exchange two shared locks.

Parameters
leftFirst lock.
rightSecond lock.

◆ swap() [10/19]

void StormByte::Safe::swap ( String & left,
String & right )
inlinenoexcept

Swaps two texts.

Parameters
leftFirst text.
rightSecond text.

◆ swap() [11/19]

void StormByte::Safe::swap ( Thread & left,
Thread & right )
inlinenoexcept

Exchange two executions.

Parameters
leftLeft thread.
rightRight thread.

◆ swap() [12/19]

template<class T>
void StormByte::Safe::swap ( Unique< T > & left,
Unique< T > & right )
noexcept

Exchange two owners.

Template Parameters
TPointee.
Parameters
leftOwner.
rightOwner.

◆ swap() [13/19]

void StormByte::Safe::swap ( UniqueLock & left,
UniqueLock & right )
inlinenoexcept

Exchange two locks.

Parameters
leftFirst lock.
rightSecond lock.

◆ swap() [14/19]

template<Type::SafeValue K, Type::SafeValue V, class Hash, class KeyEqual>
void StormByte::Safe::swap ( UnorderedMap< K, V, Hash, KeyEqual > & left,
UnorderedMap< K, V, Hash, KeyEqual > & right )
noexcept

Exchange two maps.

Template Parameters
KSafe key.
VSafe mapped type.
HashKey hash.
KeyEqualKey equality.
Parameters
leftFirst map.
rightSecond map.

◆ swap() [15/19]

template<Type::SafeValue K, class Hash, class KeyEqual>
void StormByte::Safe::swap ( UnorderedSet< K, Hash, KeyEqual > & left,
UnorderedSet< K, Hash, KeyEqual > & right )
inlinenoexcept

Exchange two sets.

Template Parameters
KValue type.
HashValue hash.
KeyEqualValue equality.
Parameters
leftLeft set.
rightRight set.

◆ swap() [16/19]

template<Type::SafeValue... Ts>
void StormByte::Safe::swap ( Variant< Ts... > & left,
Variant< Ts... > & right )
noexcept

Swaps two variants.

Template Parameters
TsAlternatives.
Parameters
leftFirst variant.
rightSecond variant.

◆ swap() [17/19]

template<Type::SafeValue T>
void StormByte::Safe::swap ( Vector< T > & lhs,
Vector< T > & rhs )
noexcept

Exchange two sequences.

Parameters
lhsFirst sequence.
rhsSecond sequence.

◆ swap() [18/19]

template<class T>
void StormByte::Safe::swap ( Weak< T > & left,
Weak< T > & right )
noexcept

Exchange two observers.

Template Parameters
TPointee.
Parameters
leftObserver.
rightObserver.

◆ swap() [19/19]

void StormByte::Safe::swap ( WString & left,
WString & right )
inlinenoexcept

Swaps two texts.

Parameters
leftFirst text.
rightSecond text.

◆ ThrowDequeOutOfBounds() [1/2]

void StormByte::Safe::ThrowDequeOutOfBounds ( )

Throw the deque out-of-bounds error from Base.

Exceptions
OutOfBoundsErrorAlways.

◆ ThrowDequeOutOfBounds() [2/2]

void StormByte::Safe::ThrowDequeOutOfBounds ( const Size & index)

◆ ThrowQueueOutOfBounds()

void StormByte::Safe::ThrowQueueOutOfBounds ( )

Throw the queue out-of-bounds error from Base.

Exceptions
OutOfBoundsErrorAlways.

◆ ThrowVectorOutOfBounds() [1/2]

void StormByte::Safe::ThrowVectorOutOfBounds ( )

Throw the vector out-of-bounds error from Base.

Exceptions
OutOfBoundsErrorAlways.

◆ ThrowVectorOutOfBounds() [2/2]

void StormByte::Safe::ThrowVectorOutOfBounds ( const Size & index)

◆ visit() [1/2]

template<class Visitor, Type::SafeValue... Ts>
decltype(auto) StormByte::Safe::visit ( Visitor && visitor,
const Variant< Ts... > & value )

Call visitor with the active alternative.

Template Parameters
VisitorCallable.
TsAlternatives.
Parameters
visitorCallable.
valueVariant.
Returns
Whatever visitor returns.
Exceptions
BadVariantAccessvalue is valueless.

◆ visit() [2/2]

template<class Visitor, Type::SafeValue... Ts>
decltype(auto) StormByte::Safe::visit ( Visitor && visitor,
Variant< Ts... > & value )

Call visitor with the active alternative.

Template Parameters
VisitorCallable.
TsAlternatives.
Parameters
visitorCallable.
valueVariant.
Returns
Whatever visitor returns.
Exceptions
BadVariantAccessvalue is valueless.

Variable Documentation

◆ adopt_lock

AdoptLock StormByte::Safe::adopt_lock {}
inlineconstexpr

Tag value for AdoptLock.

◆ defer_lock

DeferLock StormByte::Safe::defer_lock {}
inlineconstexpr

Tag value for DeferLock.

◆ try_to_lock

TryToLock StormByte::Safe::try_to_lock {}
inlineconstexpr

Tag value for TryToLock.