Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/spec/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ nav:
- proxy_indirect_accessor: proxy_indirect_accessor
- proxy_view<br />observer_facade: proxy_view.md
- proxy: proxy
- substitution_dispatch: substitution_dispatch
- weak_dispatch: weak_dispatch
- weak_proxy<br />weak_facade: weak_proxy.md
- Alias Templates:
Expand Down
1 change: 0 additions & 1 deletion docs/spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ This document provides the API specifications for the C++ library Proxy (version
| [`proxy_indirect_accessor`](proxy_indirect_accessor/README.md) | Provides indirection accessibility for `proxy` |
| [`proxy_view`<br />`observer_facade`](proxy_view.md) | Non-owning `proxy` optimized for raw pointer types |
| [`proxy`](proxy/README.md) | Wraps a pointer object matching specified facade |
| [`substitution_dispatch`](substitution_dispatch/README.md) | Dispatch type for `proxy` substitution with accessibility |
| [`weak_dispatch`](weak_dispatch/README.md) | Weak dispatch type with a default implementation that throws `not_implemented` |
| [`weak_proxy`<br />`weak_facade`](weak_proxy.md) | `proxy` with weak ownership |

Expand Down
2 changes: 1 addition & 1 deletion docs/spec/basic_facade_builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ using facade_builder =
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| [`add_convention`<br />`add_indirect_convention`<br />`add_direct_convention`](add_convention.md) | Adds a convention to the template parameters |
| [`add_facade`](add_facade.md) | Adds a facade to the template parameters |
| [`add_facade_with_substitution`](add_facade_with_substitution.md) | Adds a facade to the template parameters, together with [substitution](../substitution_dispatch/README.md) support |
| [`add_facade_with_substitution`](add_facade_with_substitution.md) | Equivalent to [`add_facade`](add_facade.md) |
| [`add_reflection`<br />`add_indirect_reflection`<br />`add_direct_reflection`](add_reflection.md) | Adds a reflection to the template parameters |
| [`add_skill`](add_skill.md) | Adds a custom skill |
| [`restrict_layout`](restrict_layout.md) | Specifies maximum `MaxSize` and `MaxAlign` in the template parameters |
Expand Down
5 changes: 2 additions & 3 deletions docs/spec/basic_facade_builder/add_facade.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ The alias template `add_facade` of `basic_facade_builder<Ss, Cs, Rs, MaxSize, Ma

The conventions and reflections of `F` are not copied into `Cs` or `Rs`. They are reached through the super. Adding the same facade more than once, or redeclaring a convention that a super already provides, is well-defined and does not have side effects on [`build`](build.md) at either compile-time or runtime.

A convention whose overload is a specialization of [`facade_aware_overload_t`](../facade_aware_overload_t.md) is the exception: its overload depends on the facade it is built into, so it is also checked and made available against the built facade, not only against the super that declares it. [`proxiable`](../proxiable.md) therefore requires the pointer type to satisfy both substitutions, and a failure of either is diagnosed. This is what lets a skill such as [`as_view`](../skills_as_view.md) declared on a super yield a [`proxy_view`](../proxy_view.md) of the built facade rather than of the super.
A convention whose overload is a specialization of [`facade_aware_overload_t`](../facade_aware_overload_t.md) is the exception: its overload depends on the facade it is built into, so it is also checked and made available against the built facade, not only against the super that declares it. [`proxiable`](../proxiable.md) therefore requires the pointer type to satisfy both substitutions, and a failure of either is diagnosed. This is what lets a skill such as [`as_view`](../skills_as_view.md) declared on a super yield a [`proxy_view`](../proxy_view.md) of the built facade as well as of the super.

The metadata of the built facade embeds the metadata of each super, so that converting to a `proxy<F>` needs no indirect call to translate the metadata. The contained value is still copied or relocated as it would be by a copy or a move of a `proxy` of the built facade, which involves an indirect call unless the corresponding [`constraint_level`](../constraint_level.md) is `trivial`. Two consequences of embedding are worth noting. When a super is reachable through more than one other super (a diamond), its metadata is embedded once per path. When the built facade strengthens a [`constraint_level`](../constraint_level.md) that `F` also declares (for example from `nontrivial` to `nothrow`), both levels are represented. Either case makes the metadata larger than the sum of the distinct conventions, and nesting diamonds compounds the effect. Metadata of that size is held out of line and shared by every `proxy` of the facade, so the cost is in static data rather than in `sizeof(proxy<F>)`.

A [`proxy`](../proxy/README.md) of the built facade converts to a `proxy<F>`, subject to the copyability and relocatability of `F`.
A [`proxy`](../proxy/README.md) of the built facade converts to a `proxy<F>`, subject to the copyability and relocatability of `F`. It also converts to a [`proxy_view`](../proxy_view.md)`<F>` when [`as_view`](../skills_as_view.md) is in effect, and to a [`weak_proxy`](../weak_proxy.md)`<F>` when [`as_weak`](../skills_as_weak.md) is.

## Example

Expand Down Expand Up @@ -89,5 +89,4 @@ int main() {

## See Also

- [`add_facade_with_substitution`](add_facade_with_substitution.md)
- [`build`](build.md)
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ template <facade F>
using add_facade_with_substitution = basic_facade_builder</* see below */>;
```

The alias template `add_facade_with_substitution` of `basic_facade_builder<Cs, Rs, MaxSize, MaxAlign, Copyability, Relocatability, Destructibility>` is equivalent to [`add_facade`](add_facade.md)`<F>`, except that it always merges a direct convention of [`substitution_dispatch`](../substitution_dispatch/README.md) into `Cs`. This convention enables substitution from a `proxy` of the built [facade](../facade.md) to a `proxy<F>`.

## Notes

`add_facade_with_substitution` was introduced in `4.1.0` as a replacement for the deprecated `add_facade<F, true>` syntax.

The substitution convention is helpful when an API requires backward compatibility, at the cost of potentially a slightly larger binary size. When substitution is not required, use [`add_facade`](add_facade.md) to guarantee minimal binary size in code generation.
The alias template `add_facade_with_substitution` of `basic_facade_builder<Ss, Cs, Rs, MaxSize, MaxAlign, Copyability, Relocatability, Destructibility>` is equivalent to [`add_facade`](add_facade.md)`<F>`.

## Example

Expand Down
2 changes: 1 addition & 1 deletion docs/spec/proxy_view.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using proxy_view = proxy<observer_facade<F>>;
| Name | Description |
| ---------------------------------- | ------------------------------------------------------------ |
| `super_types`<br />*(since 5.0.0)* | A [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type transformed from `typename F::super_types`. Specifically, for each super `G` in `typename F::super_types`, `observer_facade<G>` is included. |
| `convention_types` | A [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type transformed from `typename F::convention_types`. Specifically, for each convention `C` in `typename F::convention_types`:<br />- If `C::is_direct` is `false`, include `C` unchanged.<br />- Otherwise, if `typename C::dispatch_type` is [`substitution_dispatch`](./substitution_dispatch/README.md), include a transformed convention `C'` whose `is_direct` is `true`, `dispatch_type` is still `substitution_dispatch`, and whose `overload_type` is `typename C::overload_type` with a return type of `proxy<G>` replaced by `proxy_view<G>` and qualifiers replaced by `const noexcept`.<br />- Otherwise `C` is discarded. Duplicates are removed. |
| `convention_types` | A [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type transformed from `typename F::convention_types`. Specifically, for each convention `C` in `typename F::convention_types`, `C` is included when `C::is_direct` is `false`, or otherwise discarded. |
| `reflection_types` | A [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type transformed from `typename F::reflection_types`. Specifically, for each reflection type `R` in `typename F::reflection_types`, `R` is included when `R::is_direct` is `false`, or otherwise discarded. |

## Member Constants of `observer_facade`
Expand Down
6 changes: 4 additions & 2 deletions docs/spec/skills_as_view.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ template <class FB>
using as_view = /* see below */;
```

The alias template `as_view` modifies a specialization of [`basic_facade_builder`](basic_facade_builder/README.md) to allow implicit conversion from [`proxy`](proxy/README.md)`<F>` to [`proxy_view`](proxy_view.md)`<F>`, where `F` is a built [facade](facade.md) type.
The alias template `as_view` modifies a specialization of [`basic_facade_builder`](basic_facade_builder/README.md) to allow implicit conversion from [`proxy`](proxy/README.md)`<F>` to [`proxy_view`](proxy_view.md)`<G>`, where `F` is a built [facade](facade.md) type and `G` is `F` or a super of `F`, reachable via `typename F::super_types` transitively. *Since 5.0.0*: conversion to a view of a super is allowed. Previously only `proxy_view<F>` was available.

Let `p` be a value of type `proxy<F>`, `ptr` be the contained value of `p` (if any), the conversion from type `proxy<F>&` to type `proxy_view<F>` is equivalent to `return observer-ptr{std::addressof(*ptr)}` if `p` contains a value, or otherwise equivalent to `return nullptr`. `observer-ptr` is an exposition-only type that `*observer-ptr`, `*std::as_const(observer-ptr)`, `*std::move(observer-ptr)` and `*std::move(std::as_const(observer-ptr))` are equivalent to `*ptr`, `*std::as_const(ptr)`, `*std::move(ptr)` and `*std::move(std::as_const(ptr))`, respectively.
Let `p` be a value of type `proxy<F>`, `ptr` be the contained value of `p` (if any), the conversion from type `proxy<F>&` to type `proxy_view<G>` is equivalent to `return observer-ptr{std::addressof(*ptr)}` if `p` contains a value, or otherwise equivalent to `return nullptr`. `observer-ptr` is an exposition-only type that `*observer-ptr`, `*std::as_const(observer-ptr)`, `*std::move(observer-ptr)` and `*std::move(std::as_const(observer-ptr))` are equivalent to `*ptr`, `*std::as_const(ptr)`, `*std::move(ptr)` and `*std::move(std::as_const(ptr))`, respectively.

## Notes

A view of a super exposes the conventions and reflections of that super. It observes the same object as `p` without taking ownership, exactly as `proxy_view<F>` does.

`as_view` is useful when a certain context does not take ownership of a `proxy` object. Similar to [`std::unique_ptr::get`](https://en.cppreference.com/w/cpp/memory/unique_ptr/get), [`std::shared_ptr::get`](https://en.cppreference.com/w/cpp/memory/shared_ptr/get) and the [borrowing mechanism in Rust](https://doc.rust-lang.org/rust-by-example/scope/borrow.html).

## Example
Expand Down
4 changes: 2 additions & 2 deletions docs/spec/skills_as_weak.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ template <class FB>
using as_weak = /* see below */;
```

The alias template `as_weak` modifies a specialization of [`basic_facade_builder`](basic_facade_builder/README.md) to allow implicit conversion from [`proxy`](proxy/README.md)`<F>` to [`weak_proxy`](weak_proxy.md)`<F>`, where `F` is a built [facade](facade.md) type.
The alias template `as_weak` modifies a specialization of [`basic_facade_builder`](basic_facade_builder/README.md) to allow implicit conversion from [`proxy`](proxy/README.md)`<F>` to [`weak_proxy`](weak_proxy.md)`<G>`, where `F` is a built [facade](facade.md) type and `G` is `F` or a super of `F`, reachable via `typename F::super_types` transitively, for which converting `weak_proxy<F>` to `weak_proxy<G>` is not potentially-throwing. *Since 5.0.0*: conversion to a weak proxy of a super is allowed. Previously only `weak_proxy<F>` was available.

Let `p` be a value of type `proxy<F>`, `ptr` be the contained value of `p` (if any), `Ptr` be the type of `ptr`, the conversion from type `const proxy<F>&` to type `weak_proxy<F>` is equivalent to `return typename Ptr::weak_type{p}` if `p` contains a value, or otherwise equivalent to `return nullptr`.
Let `p` be a value of type `proxy<F>`, `ptr` be the contained value of `p` (if any), `Ptr` be the type of `ptr`, the conversion from type `const proxy<F>&` to type `weak_proxy<G>` is equivalent to `return typename Ptr::weak_type{p}` if `p` contains a value, or otherwise equivalent to `return nullptr`.

## Example

Expand Down
4 changes: 0 additions & 4 deletions docs/spec/substitution_dispatch/.pages

This file was deleted.

71 changes: 0 additions & 71 deletions docs/spec/substitution_dispatch/README.md

This file was deleted.

28 changes: 0 additions & 28 deletions docs/spec/substitution_dispatch/accessor.md

This file was deleted.

8 changes: 0 additions & 8 deletions docs/spec/substitution_dispatch/operator_call.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/spec/weak_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using weak_proxy = proxy<weak_facade<F>>;
| Name | Description |
| ---------------------------------- | ----------- |
| `super_types`<br />*(since 5.0.0)* | A [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type transformed from `typename F::super_types`. Specifically, for each super `S` in `typename F::super_types`, `weak_facade<S>` is included. |
| `convention_types` | A [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type that always contains a direct convention whose dispatch type denotes the member function `lock` and whose overload has signature `proxy<F>() const noexcept`. Calling this overload attempts to obtain a strong `proxy<F>`; it returns an empty `proxy<F>` if the object has expired. For each direct convention `C` in `typename F::convention_types` whose `dispatch_type` is [`substitution_dispatch`](./substitution_dispatch/README.md), a transformed convention `C'` is also included, whose `is_direct` is `true`, `dispatch_type` is still `substitution_dispatch`, and whose `overload_type` is `typename C::overload_type` with a return type of `proxy<G>` replaced by `weak_proxy<G>`, preserving qualifiers. All other conventions from `F` are discarded. |
| `convention_types` | A [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type that contains a single direct convention whose dispatch type denotes the member function `lock` and whose overload has signature `proxy<F>() const noexcept`. Calling this overload attempts to obtain a strong `proxy<F>`; it returns an empty `proxy<F>` if the object has expired. All conventions from `F` are discarded. |
| `reflection_types` | A [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type that contains no types. |

## Member Constants of `weak_facade`
Expand Down
Loading
Loading