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 ofwrap
. If set tovoid
, the default constructor ofwrap
is disabled (unless theinvalid_default_ctor
option is set totrue
, see below).RefIFace
is the reference interface selected for thewrap
class. The default typeno_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 thewrap
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 ofwrap
initialises to the invalid state. Otherwise, the default constructor ofwrap
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 isexplicit
.
-
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.
-
std::size_t static_size = 48#
-
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.
-
enumerator always_explicit#
-
enum class wrap_semantics#
Enumerator representing the semantics chosen for a
wrap
class.-
enumerator value#
Value semantics.
-
enumerator reference#
-
enumerator value#
-
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 typeT
wrapped by the interfaceIFace
.
-
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 typeT
wrapped by the interfaceIFace
.
-
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 animpl
class template/template alias depending exactly on one parameter.
-
template<auto Cfg>
concept valid_config# Concept for checking that
Cfg
is a valid instance ofconfig
.Specifically, the concept is satisfied if:
config::static_align
is a power of two,config::explicit_ctor
is one of the enumerators defined inwrap_ctor
,config::semantics
is one of the enumerators defined inwrap_semantics
,if
config::copyable
is set totrue
, so isconfig::movable
(that is, a copyablewrap
must also be movable),if
config::movable
is set totrue
, so isconfig::swappable
(that is, a movablewrap
must also be swappable).