Utilities#

template<typename T>
using unwrap_cvref_t = std::remove_cvref_t<std::unwrap_reference_t<T>>#

A shorthand type alias that removes std::reference_wrapper, const/volatile and reference qualifiers (in that order) from T.

template<typename IFace, typename T>
concept iface_with_impl#

This concept is satisfied if the interface IFace has an implementation for the value type T.

template<typename Holder, typename T>
requires any_holder<Holder> && std::derived_from<Holder, T>
[[nodiscard]] const auto &getval(const T *h) noexcept#
template<typename Holder, typename T>
requires any_holder<Holder> && std::derived_from<Holder, T>
[[nodiscard]] auto &getval(T *h)#
template<typename Holder, typename T>
requires any_holder<Holder> && std::derived_from<Holder, T>
[[nodiscard]] auto &getval(T &h)#

Type-erased value getters.

These getters will return a reference to the type-erased value stored in a holder of type Holder deriving from T. They are meant to be used within the implementation of an interface. Internally, they will employ the curiously recurring template pattern (CRTP) to cast h to Holder and fetch the type-erased value stored within.

If the type-erased value stored in h is a std::reference_wrapper, these getters will unwrap the reference (i.e., they will return a reference to the referenced-to value).

Parameters:

h – a pointer or reference to a holder, cast to its base type T.

Returns:

a reference to the type-erased value stored in h.

Throws:

std::runtime_error – if h type-erases a const reference and h is not a const pointer/reference.

template<typename IFace0, typename IFace1, typename ...IFaceN>
struct composite_iface : public IFace0, public IFace1, public IFaceN...#

Composite interface.

This class can be used to create a composite interface by multiply inheriting from the interfaces IFace0, IFace1 and IFaceN.

template<typename T>
concept valid_value_type = std::is_object_v<T> && (!std::is_const_v<T>) && (!std::is_volatile_v<T>) && std::destructible<T>#

This concept detects if T is a type that can be type-erased by a wrap.

T must be a non-cv qualified destructible object.

template<typename IFace, typename Base, typename Holder, typename T>
struct iface_impl#

Non-intrusive interface implementation.

This class can be partially specialised to specify a non-intrusive implementation for the interface IFace. See the tutorial for an example.

The unspecialised version of this class is an empty trivial structure which disables non-intrusive implementations for the interface IFace.