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 as Cs
, andtypename build::reflection_types
is defined as Rs
, andbuild::constraints
is a core constant expression of type proxiable_ptr_constraints
that defines constraints to the pointer types, andbuild::constraints.max_size
is C::max_size
if defined by restrict_layout
, otherwise sizeof(void*) * 2u
when C::max_size
is default-size, andbuild::constraints.max_align
is C::max_align
if defined by restrict_layout
, otherwise alignof(void*)
when C::max_align
is default-size, andbuild::constraints.copyability
is C::copyability
if defined by support_copy
, otherwise constraint_level::none
when C::copyability
is default-cl, andbuild::constraints.relocatability
is C::relocatability
if defined by support_rellocation
, otherwise constraint_level::nothrow
when C::relocatability
is default-cl, andbuild::constraints.destructibility
is C::destructibility
if defined by support_destruction
, otherwise constraint_level::nothrow
when C::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;
}
Name | Definition |
---|---|
convention_types |
Cs |
reflection_types |
Rs |
Name | Definition |
---|---|
constraints [static] [constexpr] |
normalize(C) |
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.
#include <type_traits>
#include "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>>);
}