Common System 0.2.0
Common interfaces and patterns for system integration
Loading...
Searching...
No Matches
kcenon::common::concepts::Unwrappable Concept Referenceexport

A type that supports value extraction (unwrapping). More...

#include <core.h>

Concept definition

template<typename T>
concept kcenon::common::concepts::Unwrappable = requires(T t) {
typename T::value_type;
{ t.unwrap() } -> std::same_as<typename std::add_lvalue_reference<
typename std::add_const<typename T::value_type>::type>::type>;
{ t.unwrap_or(std::declval<typename T::value_type>()) }
-> std::convertible_to<typename T::value_type>;
}
A type that supports value extraction (unwrapping).
Definition core.h:75

Detailed Description

A type that supports value extraction (unwrapping).

Types satisfying this concept can extract their contained value either directly (with potential exception) or with a default fallback.

Example usage:

template<Unwrappable U>
auto get_or_default(const U& container, typename U::value_type default_val) {
return container.unwrap_or(default_val);
}

Definition at line 75 of file core.h.