C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Flat Member Pointer for Indirect Non-static Members

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sun, 16 Aug 2026 08:51:04 -0700
On Saturday, 15 August 2026 09:41:36 Pacific Daylight Time SD SH via Std-
Proposals wrote:
> For this case, the offsets of all `A::value` are known in compile time,
> but `bool A<T>::*` and `bool A<U>::*` cannot be converted to one another, so
> using array of member pointers doesn't work either.
>
> Similarly, because type packs cannot be expanded directly as members, the
> elements cannot all be direct members of `std::tuple`, which prevents
> member pointers for all members from being obtained, even though elements
> are unnamed.
>
> If member pointers can directly refer to indirect non-static members, these
> problems will be solved.

You haven't identified a problem yet.

You've identified a syntactical restriction. But what is the problem that this
solves? What code can be come more efficient or simpler? What functionality
would it enable that currently isn't possible?

I find that getting member pointers to an internal of std::tuple is not a
problem that needs solving. I don't see any reason why I would want to do
that. tuples are only supposed to be used in generic code, so what generic
reason could there be for getting member pointers to an unknown set of
template parameters?

Please don't answer with an improvement for the internals of std::tuple
itself. Since that's a Standard Library class, it is already permitted to use
optimisations not available to others.

I could see a value in the initial problem. Given:
A {
      B b {
            D d1; // B::D
            Z;
      };

I might have had a need for A::d1, but then I was forced to refactor my code
for some reason to use a middle-man B. But this is weak.


-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-08-16 15:51:16