From 74113b9b83d1d713e13b688f5280b9dce4f06581 Mon Sep 17 00:00:00 2001 From: Mingxin Wang Date: Mon, 18 Aug 2025 12:39:11 +0800 Subject: [PATCH 1/3] Revise the semantics of *ProAccessible* --- docs/spec/ProAccessible.md | 9 +- docs/spec/proxy/README.md | 7 +- docs/spec/proxy_indirect_accessor.md | 5 +- include/proxy/v4/proxy.h | 188 +++++++++++++-------------- 4 files changed, 107 insertions(+), 102 deletions(-) diff --git a/docs/spec/ProAccessible.md b/docs/spec/ProAccessible.md index 150e717c..c2612174 100644 --- a/docs/spec/ProAccessible.md +++ b/docs/spec/ProAccessible.md @@ -1,11 +1,12 @@ # Named requirements: *ProAccessible* -Given that `F` is a type meeting the [*ProBasicFacade* requirements](ProBasicFacade.md), a type `T` meets the *ProAccessible* requirements of type `F`, if the following expressions are well-formed and have the specified semantics. +A type `T` meets the *ProAccessible* requirements of types `Args...` if the following expressions are well-formed and have the specified semantics. -| Expressions | Semantics | -| ---------------------------------- | ------------------------------------------------------------ | -| `typename T::template accessor` | A type that provides accessibility to `proxy`. It shall be a *nothrow-default-constructible*, *trivially-copyable* type, and shall not be [final](https://en.cppreference.com/w/cpp/language/final). | +| Expressions | Semantics | +| ---------------------------------------- | ------------------------------------------------------------ | +| `typename T::template accessor` | A type that provides accessibility to `proxy`. It shall be a *nothrow-default-constructible*, *trivially-copyable* type, and shall not be [final](https://en.cppreference.com/w/cpp/language/final). | ## See Also - [class template `proxy`](proxy/README.md) +- [class template `proxy_indirect_accessor`](proxy_indirect_accessor.md) diff --git a/docs/spec/proxy/README.md b/docs/spec/proxy/README.md index 19064dbe..5335fdd4 100644 --- a/docs/spec/proxy/README.md +++ b/docs/spec/proxy/README.md @@ -11,10 +11,13 @@ class proxy; Class template `proxy` is a general-purpose polymorphic wrapper for C++ objects. Unlike other polymorphic wrappers in the C++ standard (e.g., [`std::function`](https://en.cppreference.com/w/cpp/utility/functional/function), [`std::move_only_function`](https://en.cppreference.com/w/cpp/utility/functional/move_only_function), [`std::any`](https://en.cppreference.com/w/cpp/utility/any), etc.), `proxy` is based on pointer semantics. It supports flexible lifetime management without runtime [garbage collection (GC)](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)), and offers best-in-class code generation quality, extendibility and accessibility. -As per `facade`, `typename F::convention_types` shall be a [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type containing any number of distinct types `Cs`, and `typename F::reflection_types` shall be a [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type containing any number of distinct types `Rs`. For each type `T` in `Cs` or `Rs`, if `T` meets the [*ProAccessible* requirements](../ProAccessible.md) of `F`, `typename T::template accessor` is inherited by `proxy` when `T::is_direct` is `true`. Otherwise, it is inherited by [`proxy_indirect_accessor`](../proxy_indirect_accessor.md), the return type of [`operator*`](indirection.md), when `T::is_direct` is `false`. It is recommended to use [`facade_builder`](../basic_facade_builder/README.md) to define a facade type. - Any instance of `proxy` at any given point in time either *contains a value* or *does not contain a value*. If a `proxy` *contains a value*, the type of the value shall be a pointer type `P` where [`proxiable`](../proxiable.md) is `true`, and the value is guaranteed to be allocated as part of the `proxy` object footprint, i.e. no dynamic memory allocation occurs. However, `P` may allocate during its construction, depending on its implementation. +As per `facade`, `typename F::convention_types` shall be a [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type containing any number of distinct types `Cs`, and `typename F::reflection_types` shall be a [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type containing any number of distinct types `Rs`. + +- For each type `C` in `Cs`, if `C::is_direct` is `true` and `typename C::dispatch_type` meets the [*ProAccessible* requirements](../ProAccessible.md) of `proxy, typename C::dispatch_type, substituted-overload-types...`, `typename C::dispatch_type::template accessor, typename C::dispatch_type, substituted-overload-types...>` is inherited by `proxy`. Let `Os...` be the element types of `typename C::overload_types`, `substituted-overload-types...` is [`substituted-overload...`](../ProOverload.md). +- For each type `R` in `Rs`, if `R::is_direct` is `true` and `typename R::reflector_type` meets the [*ProAccessible* requirements](../ProAccessible.md) of `proxy, typename R::reflector_type`, `typename R::reflector_type::template accessor, typename R::reflector_type` is inherited by `proxy`. + ## Member Types | Name | Description | diff --git a/docs/spec/proxy_indirect_accessor.md b/docs/spec/proxy_indirect_accessor.md index 68a0e746..ddb4c2aa 100644 --- a/docs/spec/proxy_indirect_accessor.md +++ b/docs/spec/proxy_indirect_accessor.md @@ -10,7 +10,10 @@ template class proxy_indirect_accessor; ``` -Class template `proxy_indirect_accessor` provides indirection accessibility for `proxy`. As per `facade`, `typename F::convention_types` shall be a [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type containing any number of distinct types `Cs`, and `typename F::reflection_types` shall be a [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type containing any number of distinct types `Rs`. For each type `T` in `Cs` or `Rs`, if `T` meets the [*ProAccessible* requirements](ProAccessible.md) of `F` and `T::is_direct` is `false`, `typename T::template accessor` is inherited by `proxy_indirect_accessor`. +Class template `proxy_indirect_accessor` provides indirection accessibility for `proxy`. As per `facade`, `typename F::convention_types` shall be a [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type containing any number of distinct types `Cs`, and `typename F::reflection_types` shall be a [tuple-like](https://en.cppreference.com/w/cpp/utility/tuple/tuple-like) type containing any number of distinct types `Rs`. + +- For each type `C` in `Cs`, if `C::is_direct` is `false` and `typename C::dispatch_type` meets the [*ProAccessible* requirements](ProAccessible.md) of `proxy_indirect_accessor, typename C::dispatch_type, substituted-overload-types...`, `typename C::dispatch_type::template accessor, typename C::dispatch_type, substituted-overload-types...>` is inherited by `proxy_indirect_accessor`. Let `Os...` be the element types of `typename C::overload_types`, `substituted-overload-types...` is [`substituted-overload...`](ProOverload.md). +- For each type `R` in `Rs`, if `R::is_direct` is `false` and `typename R::reflector_type` meets the [*ProAccessible* requirements](ProAccessible.md) of `proxy_indirect_accessor, typename R::reflector_type`, `typename R::reflector_type::template accessor, typename R::reflector_type` is inherited by `proxy_indirect_accessor`. ## Member Functions diff --git a/include/proxy/v4/proxy.h b/include/proxy/v4/proxy.h index 452e3260..2e4b9f23 100644 --- a/include/proxy/v4/proxy.h +++ b/include/proxy/v4/proxy.h @@ -71,6 +71,19 @@ struct reduction_traits { using type = typename R::type; }; +template +struct composition_traits : std::type_identity {}; +template