61 template <
typename T,
class E>
64 std::expected<std::reference_wrapper<std::remove_reference_t<T>>,
Shared<E>>,
65 std::expected<T, Shared<E>>
76 return std::unexpected<Shared<E>>(std::move(error));
94 !
requires {
typename std::remove_cvref_t<E>::element_type; } ||
95 !Type::SameAs<std::remove_cvref_t<E>, Shared<typename std::remove_cvref_t<E>::element_type>>
98 using Error = std::decay_t<E>;
99 return std::unexpected<Shared<Error>>(
100 Heap::MakeShared<Error>(std::forward<E>(error))
111 template <
typename Base,
typename Derived>
112 auto Unexpected(Derived&& error) -> std::unexpected<Shared<Base>>
116 using DerivedT = std::decay_t<Derived>;
117 return std::unexpected<Shared<Base>>(
133 template <
typename E,
typename... Args>
135 std::string formatted_message;
137 if constexpr (
sizeof...(Args) == 0) {
138 formatted_message = fmt;
140 auto format_args = std::make_format_args(args...);
141 formatted_message = std::vformat(fmt, format_args);
144 return std::unexpected<Shared<E>>(
145 Heap::MakeShared<E>(std::move(formatted_message))
Shared owner of a T allocated on Base's heap.
Definition safe_pointers.hxx:201
Derived derives from Base (std::is_base_of).
Definition relations.hxx:113
Lvalue or rvalue reference type.
Definition categories.hxx:81
Same type after stripping cv and references from both sides.
Definition relations.hxx:94
Root namespace of the StormByte suite.
auto Unexpected(Shared< E > error)
Forwards an error already stored by Expected.
Definition expected.hxx:75
std::conditional_t< Type::Reference< T >, std::expected< std::reference_wrapper< std::remove_reference_t< T > >, Shared< E > >, std::expected< T, Shared< E > > > Expected
std::expected alias with reference and shared-error handling.
Definition expected.hxx:66
DLL-safe shared and unique owners.