proxy

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,

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.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>>);
}

See Also