[super! 5/6] Add super facades - #74
Open
mingxwa wants to merge 1 commit into
Open
Conversation
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.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes
super_typesto the facade requirements.add_facade<F>recordsFthere instead of copying its conventions and reflections, so the two facades share metadata rather than only behavior.const proxy_meta<Derived>&converts toconst proxy_meta<Super>&. Converting aproxynow carries the metadata over directly instead of translating it through an indirect call.proxy, guarded on exactly that metadata conversion. Only the contained value is copied or relocated.as_viewdeclared on a super yield aproxy_viewof the built facade.proxiablerequires the pointer type to satisfy both substitutions and diagnoses a failure of either.super_typesthroughobserver_facadeandweak_facade, so view-ness and weak-ness are preserved when converting to a proxy of a super.*thisup front instead of failing to compile.add_facadeand ignored it.add_facade<F, true>still compiles and still converts toproxy<F>, now becauseFis a super rather than through a substitution convention.Compatibility
add_facade_with_substitutionandsubstitution_dispatchare unchanged and still take precedence where both apply. Both are addressed in stage 6.convention_typesof a built facade no longer contains the conventions of its supers. They are reached through the super instead. Code that inspectsconvention_typesdirectly observes this, code that uses the resultingproxydoes not.constraint_levelis represented at both levels. Metadata of that size is held out of line and shared by everyproxyof the facade, so the cost falls on static data rather than onsizeof(proxy<F>).