basic_facade_builder::build
using build = /* see below */;
Specifies a facade type deduced from the template parameters of basic_facade_builder<Cs, Rs, C>
. Specifically,
typename build::convention_types
is defined asCs
, andtypename build::reflection_types
is defined asRs
, andbuild::constraints
is a core constant expression of typeproxiable_ptr_constraints
that defines constraints to the pointer types, andbuild::constraints.max_size
isC::max_size
if defined byrestrict_layout
, otherwisesizeof(void*) * 2u
whenC::max_size
is default-size, andbuild::constraints.max_align
isC::max_align
if defined byrestrict_layout
, otherwisealignof(void*)
whenC::max_align
is default-size, andbuild::constraints.copyability
isC::copyability
if defined bysupport_copy
, otherwiseconstraint_level::none
whenC::copyability
is default-cl, andbuild::constraints.relocatability
isC::relocatability
if defined bysupport_rellocation
, otherwiseconstraint_level::nothrow
whenC::relocatability
is default-cl, andbuild::constraints.destructibility
isC::destructibility
if defined bysupport_destruction
, otherwiseconstraint_level::nothrow
whenC::destructibility
is default-cl.
The definition of type build
makes use of the following exposition-only function:
consteval proxiable_ptr_constraints normalize(proxiable_ptr_constraints value) {
if (value.max_size == default-size)
{ value.max_size = sizeof(void*) * 2u; }
if (value.max_align == default-size)
{ value.max_align = alignof(void*); }
if (value.copyability == default-cl)
{ value.copyability = constraint_level::none; }
if (value.relocatability == default-cl)
{ value.relocatability = constraint_level::nothrow; }
if (value.destructibility == default-cl)
{ value.destructibility = constraint_level::nothrow; }
return value;
}
Member Types
Name | Definition |
---|---|
convention_types |
Cs |
reflection_types |
Rs |
Member Constants
Name | Definition |
---|---|
constraints [static] [constexpr] |
normalize(C) |
Notes
It is encouraged to inherit build
with an empty struct
before specifying a proxy
, rather than using
or typedef
the build
type into an alias, to improve compilation performance.
The default values of the fields of proxiable_ptr_constraints
are based on our engineering practices. The default values of max_size
and max_alignment
are usually sufficient for many implementations of fancy pointers, such as std::unique_ptr
, std::shared_ptr
, and boost::interprocess::offset_ptr
. A larger combination of size and alignment ensures better compatibility with the implementation of the underlying pointers and reduces heap allocation when the element type fits in the buffer (see function template make_proxy
), at the cost of making the corresponding proxy
objects larger.
Example
#include <type_traits>
#include <proxy/proxy.h>
struct DefaultBase : pro::facade_builder
::build {};
struct CopyableBase : pro::facade_builder
::support_copy<pro::constraint_level::nontrivial>
::build {};
struct TrivialBase : pro::facade_builder
::support_copy<pro::constraint_level::trivial>
::support_relocation<pro::constraint_level::trivial>
::support_destruction<pro::constraint_level::trivial>
::restrict_layout<sizeof(void*)>
::build {};
int main() {
static_assert(!std::is_copy_constructible_v<pro::proxy<DefaultBase>>);
static_assert(std::is_nothrow_move_constructible_v<pro::proxy<DefaultBase>>);
static_assert(std::is_nothrow_destructible_v<pro::proxy<DefaultBase>>);
static_assert(std::is_copy_constructible_v<pro::proxy<CopyableBase>>);
static_assert(std::is_nothrow_move_constructible_v<pro::proxy<CopyableBase>>);
static_assert(std::is_nothrow_destructible_v<pro::proxy<CopyableBase>>);
static_assert(std::is_trivially_copy_constructible_v<pro::proxy<TrivialBase>>);
static_assert(std::is_trivially_move_constructible_v<pro::proxy<TrivialBase>>);
static_assert(std::is_trivially_destructible_v<pro::proxy<TrivialBase>>);
}