This repository was archived by the owner on Jan 29, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 222
Revise documentation #355
Merged
Merged
Revise documentation #355
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| nav: | ||
| - substitution_dispatch: README.md | ||
| - accessor: accessor.md | ||
| - operator(): operator_call.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Class `substitution_dispatch` | ||
|
|
||
| > Header: `proxy.h` | ||
| > Module: `proxy` | ||
| > Namespace: `pro::inline v4` | ||
| > Since: 4.0.1 | ||
|
|
||
| ```cpp | ||
| class substitution_dispatch; | ||
| ``` | ||
|
|
||
| Class `substitution_dispatch` models a [dispatch](../ProDispatch.md) type for `proxy` substitution. It meets the [*ProAccessible* requirements](../ProAccessible.md) of applicable types. | ||
|
|
||
| ## Member Functions | ||
|
|
||
| | Name | Description | | ||
| | -------------------------------- | -------------------------------------------- | | ||
| | (constructor) [nothrow] | constructs an `substitution_dispatch` object | | ||
| | [`operator()`](operator_call.md) | invokes the dispatch | | ||
|
|
||
| ## Member Types | ||
|
|
||
| | Name | Description | | ||
| | ------------------------- | --------------------------------- | | ||
| | [`accessor`](accessor.md) | provides accessibility to `proxy` | | ||
|
|
||
| ## Example | ||
|
|
||
| ```cpp | ||
| #include <iostream> | ||
|
|
||
| #include <proxy/proxy.h> | ||
|
|
||
| struct Runnable : pro::facade_builder // | ||
| ::add_convention<pro::operator_dispatch<"()">, void()> // | ||
| ::build {}; | ||
|
|
||
| struct CopyableRunnable : pro::facade_builder // | ||
| ::support_copy<pro::constraint_level::nontrivial> // | ||
| ::add_facade<Runnable> // | ||
| ::add_direct_convention<pro::substitution_dispatch, | ||
| pro::proxy<Runnable>() const&, | ||
| pro::proxy<Runnable>() &&> // | ||
| ::build {}; | ||
|
|
||
| int main() { | ||
| pro::proxy<CopyableRunnable> p1 = pro::make_proxy<CopyableRunnable>( | ||
| [] { std::cout << "Lambda expression invoked\n"; }); | ||
|
|
||
| // Implicit conversion via const reference of pro::proxy<CopyableRunnable> | ||
| pro::proxy<Runnable> p2 = p1; | ||
| std::cout << std::boolalpha << p2.has_value() << "\n"; // Prints "true" | ||
|
|
||
| // Implicit conversion via rvalue reference of pro::proxy<CopyableRunnable> | ||
| pro::proxy<Runnable> p3 = std::move(p1); | ||
| std::cout << p1.has_value() << "\n"; // Prints "false" | ||
| (*p3)(); // Prints "Lambda expression invoked" | ||
|
|
||
| // Different from implicit_conversion_dispatch, substitution from a null proxy | ||
| // is well-formed | ||
| pro::proxy<Runnable> p4 = p1; | ||
| std::cout << p4.has_value() << "\n"; // Prints "false" | ||
| } | ||
| ``` | ||
|
|
||
| ## See Also | ||
|
|
||
| - [`basic_facade_builder::add_facade`](../basic_facade_builder/add_facade.md) | ||
| - [alias template `skills::as_view`](../skills_as_view.md) | ||
| - [alias template `skills::as_weak`](../skills_as_weak.md) | ||
| - [class `implicit_conversion_dispatch`](../implicit_conversion_dispatch/README.md) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Class template `substitution_dispatch::accessor` | ||
|
|
||
| ```cpp | ||
| // (1) | ||
| template <class P, class D, class... Os> | ||
| struct accessor { | ||
| accessor() = delete; | ||
| }; | ||
|
|
||
| // (2) | ||
| template <class P, class D, class... Os> | ||
| requires(sizeof...(Os) > 1u && (std::is_constructible_v<accessor<P, D, Os>> && ...)) | ||
| struct accessor<P, D, Os...> : accessor<P, D, Os>... { | ||
| using accessor<P, D, Os>::operator return-type-of<Os>...; | ||
| }; | ||
|
|
||
| // (3) | ||
| template <class P, class D, facade F> | ||
| struct accessor<P, D, proxy<F>() cv ref noex> { | ||
| operator proxy<F>() cv ref noex; | ||
| }; | ||
| ``` | ||
|
|
||
| `(1)` The default implementation of `accessor` is not constructible. | ||
|
|
||
| `(2)` When `sizeof...(Os)` is greater than `1`, and `accessor<P, D, Os>...` are default-constructible, inherits all `accessor<P, D, Os>...` types and `using` their `operator return-type-of<Os>`. `return-type-of<O>` denotes the *return type* of the overload type `O`. | ||
|
|
||
| `(3)` When `sizeof...(Os)` is `1` and the only type `O` in `Os` is `proxy<F>() cv ref noex`, provides an implicit `operator proxy<F>()` with the same *cv ref noex* specifiers. `accessor::operator proxy<F>()` is equivalent to `return proxy_invoke<proxy<F>() cv ref noex>(static_cast<P cv <ref ? ref : &>>(*this))` when `static_cast<const P&>(*this).has_value()` is `true`, or `return nullptr` otherwise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # `substitution_dispatch::operator()` | ||
|
|
||
| ```cpp | ||
| template <class T> | ||
| T&& operator()(T&& value) const noexcept; // exposition-only | ||
| ``` | ||
|
|
||
| Returns `std::forward<T>(value)`. When `T` is not cv- or ref-qualified and [`is_bitwise_trivially_relocatable_v<T>`](../is_bitwise_trivially_relocatable.md) is `true`, conversion from the return value to any `proxy` type shall perform bitwise trivial relocation and does not require that `T` is move-constructible. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.