Skip to content

Convert out-of-line metadata into inline metadata storage - #76

Open
mingxwa wants to merge 2 commits into
ngcpp:feature/v5from
mingxwa:user/mingxwa/meta-storage-conversion
Open

Convert out-of-line metadata into inline metadata storage#76
mingxwa wants to merge 2 commits into
ngcpp:feature/v5from
mingxwa:user/mingxwa/meta-storage-conversion

Conversation

@mingxwa

@mingxwa mingxwa commented Sep 7, 2026

Copy link
Copy Markdown
Member

Changes

  • Added a converting assignment to inplace_meta_storage from static_meta_storage, so metadata held out of line can be carried into a proxy whose own metadata is held inline.
  • Moved static_meta_storage ahead of inplace_meta_storage, which is what lets the new assignment name it.
  • Added a substitution test (will cover this path after [super! 5/6] Add super facades #74).

Resolves #75

compact_facade_meta_traits holds metadata inline when it fits in a
pointer and out of line otherwise, so two facades can differ in the
storage their metadata lands in. Both storages converted only from a
storage of their own kind, so a conversion from an out-of-line source to
an inline destination did not exist.

Give inplace_meta_storage a converting assignment from
static_meta_storage that copies the converted metadata into itself, and
define static_meta_storage first so that it can be named there. The
reverse direction stays absent: static_meta_storage holds a pointer to
the static metadata of a facade, and a metadata reached from an inline
storage lives inside a proxy rather than in static storage.

Remove the converting constructors of both storages and the copy members
of inplace_meta_storage. No caller constructs one storage from another,
and the copy members only restated what is implicitly declared, since a
constructor template is never a copy constructor and an assignment
template is never a copy assignment operator.

Cover a substitution whose two facades land in different storages. On
this branch the substitution translates the metadata through an indirect
call and does not reach the new conversion, so the test passes either
way. It is the case that starts exercising the conversion once a proxy
carries metadata across facades directly.
The two converting assignments of inplace_meta_storage reached the base
subobject with static_cast<M&>(*this) and assigned to the resulting
lvalue. The only job of that cast was to name the base, and the qualified
call M::operator= names it without a cast.

The shape static_cast<X&>(*this) already means something else in this
codebase. The cast accessor uses static_cast<const P&>(*this) to reach
the pointer type from the accessor, a downcast, so reusing the shape for
an upcast made a reader stop and work out the direction. Naming M also
matches the using M::M above it, which already pulls in members of M by
name.

The two forms are equivalent. The implicitly declared copy assignment of
proxy_meta hides the one in its base, so member lookup yields the same
single candidate either way, and the conversion of the argument to
const M& happens in the same place. A translation unit that forces both
overloads to instantiate produces byte identical assembly under GCC
15.2 at -O2.
@mingxwa
mingxwa force-pushed the user/mingxwa/meta-storage-conversion branch from c084afe to 138e861 Compare September 9, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants