Skip to content

[super! 5/6] Add super facades - #74

Open
mingxwa wants to merge 1 commit into
ngcpp:feature/v5from
mingxwa:user/mingxwa/super-stage5
Open

[super! 5/6] Add super facades#74
mingxwa wants to merge 1 commit into
ngcpp:feature/v5from
mingxwa:user/mingxwa/super-stage5

Conversation

@mingxwa

@mingxwa mingxwa commented Sep 4, 2026

Copy link
Copy Markdown
Member

Changes

  • Added super_types to the facade requirements. add_facade<F> records F there instead of copying its conventions and reflections, so the two facades share metadata rather than only behavior.
  • Embedded the metadata of each super in the metadata of the built facade, so const proxy_meta<Derived>& converts to const proxy_meta<Super>&. Converting a proxy now carries the metadata over directly instead of translating it through an indirect call.
  • Added converting constructors and assignment operators to proxy, guarded on exactly that metadata conversion. Only the contained value is copied or relocated.
  • Checked facade-aware overloads against the built facade as well as against the super that declares them. This is what lets a skill such as as_view declared on a super yield a proxy_view of the built facade. proxiable requires the pointer type to satisfy both substitutions and diagnoses a failure of either.
  • Regrouped accessors per dispatch type across the facade and every super, so an overload set spanning a super and the facade deriving from it stays a single overload set.
  • Mapped super_types through observer_facade and weak_facade, so view-ness and weak-ness are preserved when converting to a proxy of a super.
  • Added the assignment fallbacks a facade that forbids relocation needs. With no move assignment to commit a temporary with, assignment empties *this up front instead of failing to compile.
  • Retained the second parameter of add_facade and ignored it. add_facade<F, true> still compiles and still converts to proxy<F>, now because F is a super rather than through a substitution convention.

Compatibility

  • add_facade_with_substitution and substitution_dispatch are unchanged and still take precedence where both apply. Both are addressed in stage 6.
  • The convention_types of a built facade no longer contains the conventions of its supers. They are reached through the super instead. Code that inspects convention_types directly observes this, code that uses the resulting proxy does not.
  • Metadata is embedded once per path, so a super reachable through several supers is represented more than once, and a strengthened constraint_level is represented at both levels. Metadata of that size is held out of line and shared by every proxy of the facade, so the cost falls on static data rather than on sizeof(proxy<F>).

add_facade<F> copied F's conventions and reflections into the built
facade. The two facades then shared behavior but had unrelated metadata,
so converting a proxy of one to a proxy of the other needed an explicit
substitution convention and an indirect call to translate.

Give a facade a super_types list. add_facade<F> records F there instead
of copying, and the metadata of the built facade embeds the metadata of
each super, so const proxy_meta<Derived>& converts to const
proxy_meta<Super>&. proxy gains converting constructors and assignment
operators guarded on exactly that conversion: the metadata is carried
over directly, and only the contained value is copied or relocated.

A convention whose overload is a facade_aware_overload_t is the
exception to "not copied": its overload depends on the facade it is
built into, so it is also checked and made available against the built
facade. That is what lets as_view declared on a super yield a
proxy_view of the built facade rather than of the super.

Accessors are formed from the conventions of the facade and of every
super, regrouped per dispatch type, so an overload set spanning a super
and the facade that derives from it stays a single overload set.
observer_facade and weak_facade map super_types through themselves, so
view-ness and weak-ness are preserved across a conversion to a super.

Assignment also grows the fallbacks a facade that forbids relocation
needs: with no move assignment to commit a temporary with, assignment
empties *this up front instead of failing to compile.

add_facade<F, true>, deprecated since 4.1.0, is removed.
The second parameter of add_facade, deprecated since 4.1.0, is retained
and ignored: a proxy of the built facade already converts to a proxy<F>
because F is a super. add_facade_with_substitution and
substitution_dispatch are unchanged and still take precedence where both
apply; they are addressed in a follow-up.
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