Skip to content

Commit 7fc49f8

Browse files
authored
Revise documentation (#355)
1 parent 26a89a7 commit 7fc49f8

File tree

19 files changed

+169
-45
lines changed

19 files changed

+169
-45
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.28)
22

3-
project(msft_proxy4 VERSION 4.0.0 LANGUAGES CXX)
3+
project(msft_proxy4 VERSION 4.0.1 LANGUAGES CXX)
44
add_library(msft_proxy4 INTERFACE)
55
set_target_properties(msft_proxy4 PROPERTIES EXPORT_NAME proxy)
66
add_library(msft_proxy4::proxy ALIAS msft_proxy4)

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Please refer to the [Proxy's Frequently Asked Questions](https://microsoft.githu
4747
4848
### Hello World
4949
50-
Let's get started with the following "Hello World" example ([run](https://godbolt.org/z/3G363xz71)):
50+
Let's get started with the following "Hello World" example ([run](https://godbolt.org/z/f7W36f3se)):
5151
5252
```cpp
5353
#include <format>
@@ -61,7 +61,7 @@ struct Formattable : pro::facade_builder
6161
::build {};
6262
6363
int main() {
64-
std::string str = "Hello World";
64+
static std::string str = "Hello World";
6565
pro::proxy<Formattable> p1 = &str;
6666
std::cout << std::format("*p1 = {}\n", *p1); // Prints "*p1 = Hello World"
6767
@@ -98,7 +98,7 @@ Note: If you prefer the library to be consumed as a (C++20) module, refer to [C+
9898

9999
### Hello World (Stream Version)
100100

101-
In the previous "Hello World" example, we demonstrated how `proxy` could manage different types of objects and be formatted with `std::format`. While `std::format` is not the only option to print objects in C++, can we simply make `proxy` work with `std::cout`? The answer is "yes". The previous example is equivalent to the following implementation ([run](https://godbolt.org/z/xcsM3v3cY)):
101+
In the previous "Hello World" example, we demonstrated how `proxy` could manage different types of objects and be formatted with `std::format`. While `std::format` is not the only option to print objects in C++, can we simply make `proxy` work with `std::cout`? The answer is "yes". The previous example is equivalent to the following implementation ([run](https://godbolt.org/z/447aMbrbj)):
102102

103103
```cpp
104104
#include <iomanip>
@@ -112,7 +112,7 @@ struct Streamable : pro::facade_builder
112112
::build {};
113113

114114
int main() {
115-
std::string str = "Hello World";
115+
static std::string str = "Hello World";
116116
pro::proxy<Streamable> p1 = &str;
117117
std::cout << "*p1 = " << *p1 << "\n"; // Prints "p1 = Hello World"
118118

@@ -254,6 +254,7 @@ ctest --test-dir build -j
254254

255255
## Related Resources
256256

257+
- August, 2025: [Announcing Proxy 4: The Next Leap in C++ Polymorphism](https://devblogs.microsoft.com/cppblog/announcing-proxy-4-the-next-leap-in-c-polymorphism/)
257258
- May, 2025: [Published ISO C++ proposal P3086R34 Proxy: A Pointer-Semantics-Based Polymorphism Library](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3086r4.pdf)
258259
- January, 2025: [Published ISO C++ proposal P3584R0: Enrich Facade Creation Facilities for the Pointer-Semantics-Based Polymorphism Library - Proxy](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3584r0.pdf)
259260
- November, 2024: [Analyzing the Performance of the “Proxy” Library](https://devblogs.microsoft.com/cppblog/analyzing-the-performance-of-the-proxy-library/)

docs/spec/.pages

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ nav:
1818
- proxy_indirect_accessor: proxy_indirect_accessor.md
1919
- proxy_view<br />observer_facade: proxy_view.md
2020
- proxy: proxy
21+
- substitution_dispatch: substitution_dispatch
2122
- weak_dispatch: weak_dispatch
2223
- weak_proxy<br />weak_facade: weak_proxy.md
2324
- Alias Templates:

docs/spec/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ This document provides the API specifications for the C++ library Proxy (version
3131
| [`proxy_indirect_accessor`](proxy_indirect_accessor.md) | Provides indirection accessibility for `proxy` |
3232
| [`proxy_view`<br />`observer_facade`](proxy_view.md) | Non-owning `proxy` optimized for raw pointer types |
3333
| [`proxy`](proxy/README.md) | Wraps a pointer object matching specified facade |
34+
| [`substitution_dispatch`](substitution_dispatch/README.md) | Dispatch type for `proxy` substitution with accessibility |
3435
| [`weak_dispatch`](weak_dispatch/README.md) | Weak dispatch type with a default implementation that throws `not_implemented` |
3536
| [`weak_proxy`<br />`weak_facade`](weak_proxy.md) | `proxy` with weak ownership |
3637

docs/spec/basic_facade_builder/add_facade.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# `basic_facade_builder::add_facade`
22

33
```cpp
4-
template <facade F, bool WithUpwardConversion = false>
4+
template <facade F, bool WithSubstitution = false>
55
using add_facade = basic_facade_builder</* see below */>;
66
```
77

@@ -14,11 +14,11 @@ The alias template `add_facade` of `basic_facade_builder<Cs, Rs, MaxSize, MaxAli
1414
- sets `Copyability` to `std::max(Copyability, F::copyability)`, and
1515
- sets `Relocatability` to `std::max(Relocatability, F::relocatability)`, and
1616
- sets `Destructibility` to `std::max(Destructibility, F::destructibility)`, and
17-
- optionally, adds a convention for implicit upward conversion into `Cs` when `WithUpwardConversion` is `true`.
17+
- optionally, merges a direct convention of [`substitution_dispatch`](../substitution_dispatch/README.md) into `Cs` when `WithSubstitution` is `true`.
1818

1919
## Notes
2020

21-
Adding a facade type that contains duplicated convention or reflection types already defined in `Cs` or `Rs` is well-defined and does not have side effects on [`build`](build.md) at either compile-time or runtime. By default, `WithUpwardConversion` is `false`, which guarantees minimal binary size in code generation. However, upward conversion is helpful when an API requires backward compatibility. Users can opt-in to this feature by specifying `true` as the second parameter of `add_facade`, at the cost of potentially a slightly larger binary size.
21+
Adding a facade type that contains duplicated convention or reflection types already defined in `Cs` or `Rs` is well-defined and does not have side effects on [`build`](build.md) at either compile-time or runtime. By default, `WithSubstitution` is `false`, which guarantees minimal binary size in code generation. However, substitution is helpful when an API requires backward compatibility. Users can opt-in to this feature by specifying `true` as the second parameter of `add_facade`, at the cost of potentially a slightly larger binary size.
2222

2323
## Example
2424

@@ -68,7 +68,7 @@ int main() {
6868
auto p2 = p1; // Performs a deep copy
6969
p2->emplace(456, "trivial");
7070

71-
// Performs an upward conversion from an rvalue reference
71+
// Performs a substitution from an rvalue reference
7272
pro::proxy<StringDictionary> p3 = std::move(p2);
7373
std::cout << p1->size() << "\n"; // Prints "1"
7474
std::cout << p1->at(123) << "\n"; // Prints "lalala"

docs/spec/explicit_conversion_dispatch/accessor.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct accessor<P, D, Os...> : accessor<P, D, Os>... {
1515
};
1616

1717
// (3)
18-
template <class P, class D>
18+
template <class P, class D, class T>
1919
struct accessor<P, D, T() cv ref noex> {
2020
explicit operator T() cv ref noex;
2121
};

docs/spec/implicit_conversion_dispatch/accessor.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct accessor<P, D, Os...> : accessor<P, D, Os>... {
1515
};
1616

1717
// (3)
18-
template <class P, class D>
18+
template <class P, class D, class T>
1919
struct accessor<P, D, T() cv ref noex> {
2020
operator T() cv ref noex;
2121
};

docs/spec/msft_lib_proxy.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Starting with 3.0.0, Proxy ships a feature-test macro that encodes the library v
1010
1111
| Version | Value of `__msft_lib_proxy` |
1212
| ------- | --------------------------- |
13+
| 4.0.1 | `202510L` |
1314
| 4.0.0 | `202508L` |
1415
| 3.4.0 | `202505L` |
1516
| 3.3.0 | `202503L` |

docs/spec/proxy_view.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ template <facade F>
1313
using proxy_view = proxy<observer_facade<F>>;
1414
```
1515

16-
Class template `observer_facade` is a [facade](facade.md) type for observer pointers (e.g., raw pointers) potentially dereferenced from a `proxy` object.
16+
`proxy_view<F>` is a non-owning, trivially copyable, trivially relocatable view of an object that models [`proxiable_target<T, F>`](proxiable_target.md). It behaves like a `proxy<F>` except that it never owns the lifetime of the underlying object.
17+
18+
`observer_facade<F>` adapts an existing [facade](facade.md) `F` for this non-owning use. The adaptation preserves only those parts of `F` that remain semantically valid when the storage is reduced to a single pointer and modifies substitution conversions so that view-ness is preserved (substitution that would have produced an owning `proxy<G>` instead produces a `proxy_view<G>`).
1719

1820
## Member Types of `observer_facade`
1921

2022
| Name | Description |
2123
| ------------------ | ------------------------------------------------------------ |
22-
| `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 type `C` defined in `typename F::convention_types`, `C` is reserved when `C::is_direct` is `false` or when `C` is an upward conversion convention added via [`basic_facade_builder::add_facade<?, true>`](basic_facade_builder/add_facade.md), or otherwise filtered out. |
23-
| `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 reserved when `R::is_direct` is `false`, or otherwise filtered out. |
24+
| `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<br/> * `is_direct` is `true` and `dispatch_type` is still `substitution_dispatch`.<br/> * For every overload `O` in `typename C::overload_types` with signature (after cv/ref/noexcept qualifiers) returning a `proxy<G>`, replace its return type with `proxy_view<G>` while preserving qualifiers and `noexcept`.<br/> - Otherwise `C` is discarded. |
25+
| `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. |
2426

2527
## Member Constants of `observer_facade`
2628

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
nav:
2+
- substitution_dispatch: README.md
3+
- accessor: accessor.md
4+
- operator(): operator_call.md

0 commit comments

Comments
 (0)