Main namespace for the StormByte library.
More...
|
| template<typename T , class E > |
| using | Expected = std::conditional_t< Type::Reference< T >, std::expected< std::reference_wrapper< std::remove_reference_t< T > >, std::shared_ptr< E > >, std::expected< T, std::shared_ptr< E > > > |
| | Expected type with support for reference types.
|
| |
|
|
STORMBYTE_PUBLIC std::error_code | make_error_code (Error::Code e) |
| |
| template<typename E > |
| auto | Unexpected (std::shared_ptr< E > error_ptr) |
| | Creates an std::unexpected with a shared pointer to the error.
|
| |
| template<typename E > |
| auto | Unexpected (E &&error) |
| | Creates an std::unexpected with a new error instance.
|
| |
template<typename Base , typename Derived >
requires std::is_base_of_v<Base, std::decay_t<Derived>> |
| auto | Unexpected (Derived &&error) -> std::unexpected< std::shared_ptr< Base > > |
| | Construct an Unexpected<Base> from a Derived instance.
|
| |
| template<typename E , typename... Args> |
| auto | Unexpected (const std::string &fmt, Args &&... args) |
| | Creates an std::unexpected with a formatted error message.
|
| |
template<typename T , typename U >
requires Type::ConvertibleTo<T, U> |
| void | append_vector (std::vector< T > &dest, std::span< U > src) noexcept |
| |
| template<typename T > |
| void | append_vector (std::vector< T > &dest, const std::vector< T > &src) noexcept |
| | Appends the contents of one vector to another.
|
| |
| template<typename T > |
| void | append_vector (std::vector< T > &dest, std::vector< T > &&src) noexcept |
| | Move the contents of one vector to another.
|
| |
| STORMBYTE_PUBLIC std::string | GenerateUUIDv4 () noexcept |
| | Generate a RFC4122-compliant UUID version 4 string.
|
| |
Main namespace for the StormByte library.
The StormByte namespace serves as the root for all components and utilities in the StormByte library. It provides foundational classes and tools for building robust, thread-safe, and efficient applications.
◆ Expected
template<typename T , class E >
| using StormByte::Expected = typedef std::conditional_t< Type::Reference<T>, std::expected<std::reference_wrapper<std::remove_reference_t<T> >, std::shared_ptr<E> >, std::expected<T, std::shared_ptr<E> > > |
Expected type with support for reference types.
- Template Parameters
-
| T | Expected type |
| E | Error type |
Defines an alias for std::expected, with special handling for reference types. For reference types, the std::reference_wrapper ensures safe and efficient storage, while the error type is managed using std::shared_ptr to support dynamic allocation.
◆ append_vector() [1/2]
template<typename T >
| void StormByte::append_vector |
( |
std::vector< T > & |
dest, |
|
|
const std::vector< T > & |
src |
|
) |
| |
|
noexcept |
Appends the contents of one vector to another.
- Template Parameters
-
| T | The type of elements in the vectors. |
- Parameters
-
| dest | The destination vector to which elements will be appended. |
| src | The source vector from which elements will be taken. |
- Note
- This function reserves enough space in the destination vector to accommodate the new elements before appending, to avoid multiple reallocations.
This function appends all elements from the source vector src to the end of the destination vector dest. It supports both lvalue and rvalue source vectors for efficient appending.
◆ append_vector() [2/2]
template<typename T >
| void StormByte::append_vector |
( |
std::vector< T > & |
dest, |
|
|
std::vector< T > && |
src |
|
) |
| |
|
noexcept |
Move the contents of one vector to another.
- Template Parameters
-
| T | The type of elements in the vectors. |
- Parameters
-
| dest | The destination vector to which elements will be appended. |
| src | The source vector from which elements will be taken. |
- Note
- This function reserves enough space in the destination vector to accommodate the new elements before appending, to avoid multiple reallocations.
This function appends all elements from the source vector src to the end of the destination vector dest. It supports both lvalue and rvalue source vectors for efficient appending.
◆ GenerateUUIDv4()
| STORMBYTE_PUBLIC std::string StormByte::GenerateUUIDv4 |
( |
| ) |
|
|
noexcept |
Generate a RFC4122-compliant UUID version 4 string.
See uuid.cxx for details and implementation notes about randomness source selection (OS CSPRNG preferred, fallback to PRNG).
- Returns
- A 36-character lowercase UUID string in the form "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx" where
y is one of 8, 9, a, or b.
◆ Unexpected() [1/4]
template<typename E , typename... Args>
| auto StormByte::Unexpected |
( |
const std::string & |
fmt, |
|
|
Args &&... |
args |
|
) |
| |
Creates an std::unexpected with a formatted error message.
- Template Parameters
-
| E | Error type |
| Args | Types of arguments to format the error message |
- Parameters
-
| fmt | The format string |
| args | Arguments to format the string |
- Returns
- An
std::unexpected object containing a shared pointer to the error
Dynamically formats the error message using std::vformat and constructs the error instance with the formatted message. If no arguments are provided, it directly uses the format string as the error message.
◆ Unexpected() [2/4]
template<typename Base , typename Derived >
requires std::is_base_of_v<Base, std::decay_t<Derived>>
| auto StormByte::Unexpected |
( |
Derived && |
error | ) |
-> std::unexpected<std::shared_ptr<Base>>
|
Construct an Unexpected<Base> from a Derived instance.
Allows calling Unexpected<Base>(Derived(...)) to create a std::unexpected<std::shared_ptr<Base>> that holds a Derived instance inside the shared_ptr and upcasts it to Base.
◆ Unexpected() [3/4]
template<typename E >
| auto StormByte::Unexpected |
( |
E && |
error | ) |
|
Creates an std::unexpected with a new error instance.
- Template Parameters
-
- Parameters
-
| error | Error instance to store |
- Returns
- An
std::unexpected object containing a shared pointer to the new error instance
This overload constructs a new error instance by forwarding the provided argument.
◆ Unexpected() [4/4]
template<typename E >
| auto StormByte::Unexpected |
( |
std::shared_ptr< E > |
error_ptr | ) |
|
Creates an std::unexpected with a shared pointer to the error.
- Template Parameters
-
- Parameters
-
| error_ptr | A shared pointer to the error |
- Returns
- An
std::unexpected object containing the shared pointer to the error
This overload is used when an existing std::shared_ptr to the error instance is available.