6#ifndef SL_UTILITY_NULLABLES_BASE_HPP
7#define SL_UTILITY_NULLABLES_BASE_HPP
118 requires std::is_pointer_v<T>
122 static constexpr std::nullptr_t null{
nullptr};
129 template <
class TNullable>
132 constexpr decltype(
auto)
unwrap(
137 return *std::forward<TNullable>(na);
142 template <
class TNullable>
143 requires requires { {
unwrap(std::declval<TNullable>()) } -> std::convertible_to<value_t<TNullable>>; }
145 constexpr decltype(
auto)
operator()(TNullable&& na)
const noexcept
147 return unwrap(std::forward<TNullable>(na));
160 inline constexpr detail::unwrap_fn
unwrap{};
188 && std::is_assignable_v<std::remove_cvref_t<T>&,
decltype(null_v<T>)>;
191namespace sl::nullables::detail
214 template <concepts::unqualified Operation>
219 explicit Algorithm(Operation operation)
noexcept(std::is_nothrow_move_constructible_v<Operation>)
220 : m_Operation{std::move(operation)}
224 template <input_nullable Nullable>
225 requires std::regular_invocable<Operation, Nullable>
226 && std::is_void_v<std::invoke_result_t<Operation, Nullable>>
230 )
noexcept(std::is_nothrow_invocable_v<Operation, Nullable>)
232 return std::invoke(algorithm.m_Operation, std::forward<Nullable>(input));
235 template <input_nullable Nullable>
236 requires std::regular_invocable<Operation, Nullable>
241 )
noexcept(std::is_nothrow_invocable_v<Operation, Nullable>)
243 return std::invoke(algorithm.m_Operation, std::forward<Nullable>(input));
248 Operation m_Operation{};
256namespace sl::nullables::detail
#define SL_UTILITY_NO_UNIQUE_ADDRESS
Definition: Config.hpp:21
The core algorithm helper, which executes the held operation when used as the right-hand-side of oper...
Definition: base.hpp:216
friend constexpr auto operator|(Nullable &&input, const Algorithm &algorithm) noexcept(std::is_nothrow_invocable_v< Operation, Nullable >)
Definition: base.hpp:227
Algorithm(Operation operation) noexcept(std::is_nothrow_move_constructible_v< Operation >)
Definition: base.hpp:219
Determines whether a type can be used in unary operator * expressions and if the return type is conve...
Definition: operators.hpp:734
Checks whether the target type is constructible from the source type.
Definition: stl_extensions.hpp:78
Checks whether a symmetrical set of operators == and != to compare both types with each other exists.
Definition: stl_extensions.hpp:124
Checks whether a type is nullable.
Definition: base.hpp:186
constexpr detail::unwrap_fn unwrap
Retrieves the value of the given input_nullable.
Definition: base.hpp:160
static constexpr auto null_v
Convenience constant retrieving the null object of a nullable type.
Definition: base.hpp:111
typename traits< std::remove_cvref_t< T > >::value_type value_t
Convenience alias retrieving the value type of a nullable type.
Definition: base.hpp:104
std::remove_pointer_t< T > value_type
Definition: base.hpp:121
Definition: adapter.hpp:19
The main trait, which may be specialized from.
Definition: base.hpp:97