Configuration options#

template<typename DefaultValueType = void, typename RefIFace = no_ref_iface>
requires (std::same_as<DefaultValueType, void> || valid_value_type<DefaultValueType>) && valid_ref_iface<RefIFace>
struct config#

Configuration struct.

This struct stores tunable config options for the wrap class.

DefaultValueType represents the type used by the default constructor of wrap. If set to void, the default constructor of wrap is disabled (unless the invalid_default_ctor option is set to true, see below).

RefIFace is the reference interface selected for the wrap class. The default type no_ref_iface selects an empty reference interface.

std::size_t static_size = 48#

Threshold size (in bytes) for the small-object optimisation in the wrap class. If set to zero, the small-object optimisation is disabled and the wrap class always uses dynamically-allocated memory.

std::size_t static_align = alignof(std::max_align_t)#

Alignment (in bytes) for the small-object optimisation in the wrap class. This value must be a power of two.

bool invalid_default_ctor = false#

If this option is set to true, then the default constructor of wrap initialises to the invalid state. Otherwise, the default constructor of wrap is disabled, unless a non-void DefaultValueType is selected.

bool pointer_interface = true#

This option selects whether or not the pointer interface is enabled.

wrap_ctor explicit_ctor = wrap_ctor::always_explicit#

This option selects when the generic constructor of the wrap class is explicit.

wrap_semantics semantics = wrap_semantics::value#

This option selects the semantics for the wrap class.

bool copyable = true#

This option selects whether or not the wrap class is copy constructible/assignable.

This option is ignored when employing reference semantics.

bool movable = true#

This option selects whether or not the wrap class is move constructible/assignable.

This option is ignored when employing reference semantics.

bool swappable = true#

This option selects whether or not the wrap class is swappable.

This option is ignored when employing reference semantics.

inline constexpr auto default_config = config{}#

Default configuration for the wrap class.

struct no_ref_iface#

A placeholder type that represents an empty reference interface. This is a trivial empty struct.

enum class wrap_ctor#

Enumerator representing the explicitness of the generic constructor of the wrap class.

enumerator always_explicit#

The constructor is always explicit.

enumerator ref_implicit#

The constructor is implicit when constructing from a std::reference_wrapper, explicit otherwise.

enumerator always_implicit#

The constructor is always implicit.

enum class wrap_semantics#

Enumerator representing the semantics chosen for a wrap class.

enumerator value#

Value semantics.

enumerator reference#

Reference semantics.

template<typename T, typename IFace>
requires iface_with_impl<IFace, T>
inline constexpr std::size_t holder_size#

Helper to compute the total amount of memory (in bytes) needed to statically store in a wrap a value of type T wrapped by the interface IFace.

template<typename T, typename IFace>
requires iface_with_impl<IFace, T>
inline constexpr std::size_t holder_align#

Helper to compute the alignment (in bytes) required to statically store in a wrap a value of type T wrapped by the interface IFace.

template<typename RefIFace>
concept valid_ref_iface#

This concept is satisfied if RefIFace is a valid reference interface.

When using C++23, this concept is satisfied by any non-cv qualified class type. In C++20, RefIFace must also define in its scope an impl class template/template alias depending exactly on one parameter.

template<auto Cfg>
concept valid_config#

Concept for checking that Cfg is a valid instance of config.

Specifically, the concept is satisfied if: