Skip to content

Add independent named function dispatch and access - #100

Open
mingxwa wants to merge 1 commit into
ngcpp:feature/v5from
mingxwa:user/mingxwa/named-dispatch
Open

mingxwa wants to merge 1 commit into
ngcpp:feature/v5from
mingxwa:user/mingxwa/named-dispatch

Conversation

@mingxwa

@mingxwa mingxwa commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Motivation

  • A dispatch type defined by PRO_DEF_MEM_DISPATCH, PRO_DEF_FREE_DISPATCH or PRO_DEF_FREE_AS_MEM_DISPATCH carries an accessor, so the function it calls also fixes the name and kind of the function exposed on a proxy. Providing same-name access by default is the v4 design that v5 removes.
  • Calling one function and exposing it under another name, or as a member instead of a free function, required a hand-written dispatch type.

Design

  • member_dispatch<"name"> calls the member function name, and free_dispatch<"name"> calls the free function name. member_access<"name"> defines the member function name on proxy, and free_access<"name"> defines the hidden friend name.
  • A convention selects its dispatch type and its access type independently. The dispatch types carry no accessor, and no access type is selected for them implicitly.
  • PRO_ENABLE_MEMBER(name) and PRO_ENABLE_FREE(name) define the dispatch and access specializations for name at global namespace scope. Each name is enabled at most once per translation unit for each macro.
  • free_dispatch performs ordinary lookup from its own scope, then the namespace pro::inline v5, the namespace pro and its inline namespaces, and finally the global namespace. Argument-dependent lookup happens at instantiation.

Changes

  • Added the class templates member_dispatch, member_access, free_dispatch and free_access, declared next to operator_dispatch so that proxy_macros.h stays a macro-only header, and exported them from the proxy.v5 module.
  • Added PRO_ENABLE_MEMBER and PRO_ENABLE_FREE with their version-qualified forms and the ambiguity diagnostics of the other version-less macros.
  • Added PRO5D_DEF_FREE_ACCESSOR for access types that define hidden friends.
  • Added specification pages for the four class templates and the two macros, covering the accessor of each descriptor, the lookup rules of free_dispatch and module usage.
  • Moved the free-as-member test, the weak member dispatch of ResourceDictionary, the reflection traits tests and the module test onto the new types.
  • Replaced the shared reflection access test with a facade whose member access type combines a direct convention and a reflection and whose free access type exposes the same reflection.

**NOTE**: This targets `feature/v5`.

**Motivation**
- A dispatch type defined by `PRO_DEF_MEM_DISPATCH`, `PRO_DEF_FREE_DISPATCH` or `PRO_DEF_FREE_AS_MEM_DISPATCH` carries an accessor, so the function it calls also fixes the name and kind of the function exposed on a `proxy`. Providing same-name access by default is the v4 design that v5 removes.
- Calling one function and exposing it under another name, or as a member instead of a free function, required a hand-written dispatch type.

**Design**
- `member_dispatch<"name">` calls the member function `name`, and `free_dispatch<"name">` calls the free function `name`. `member_access<"name">` defines the member function `name` on `proxy`, and `free_access<"name">` defines the hidden friend `name`.
- A convention selects its dispatch type and its access type independently. The dispatch types carry no accessor, and no access type is selected for them implicitly.
- `PRO_ENABLE_MEMBER(name)` and `PRO_ENABLE_FREE(name)` define the dispatch and access specializations for `name` at global namespace scope. Each name is enabled at most once per translation unit for each macro.
- `free_dispatch` performs ordinary lookup from its own scope, then the namespace `pro::inline v5`, the namespace `pro` and its inline namespaces, and finally the global namespace. Argument-dependent lookup happens at instantiation.

**Changes**
- Added the class templates `member_dispatch`, `member_access`, `free_dispatch` and `free_access`, declared next to `operator_dispatch` so that `proxy_macros.h` stays a macro-only header, and exported them from the `proxy.v5` module.
- Added `PRO_ENABLE_MEMBER` and `PRO_ENABLE_FREE` with their version-qualified forms and the ambiguity diagnostics of the other version-less macros.
- Added `PRO5D_DEF_FREE_ACCESSOR` for access types that define hidden friends.
- Added specification pages for the four class templates and the two macros, covering the accessor of each descriptor, the lookup rules of `free_dispatch` and module usage.
- Moved the free-as-member test, the weak member dispatch of `ResourceDictionary`, the reflection traits tests and the module test onto the new types.
- Replaced the shared reflection access test with a facade whose member access type combines a direct convention and a reflection and whose free access type exposes the same reflection.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant