C++ Logo

sg7

Advanced search

Re: [isocpp-sg7] SG7 late paper P3493R0 - Ruminations on reflection and access

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Thu, 14 Nov 2024 22:51:50 +0100
On 14/11/2024 16.48, Herb Sutter via SG7 wrote:
> Steve, I agree, but there’s a distinction some of us are making between (A) reflecting the metadata and (B) generating code to access data. I strongly agree (B) would break encapsulation and therefore should respect access and all other language rules by default (and I say so in P3437). My view has been that we should restrict (B) by default directly, not restrict (A) because it happens to indirectly make (B) harder as a side effect.

There are no provisions in the reflection paper to apply
access checks at point (B). It might be fairly hard to do
so. Access checking in non-reflection code actually works
on "names" (which might be considered point (A)), not
on the actual access (point (B)). If a public function returns
a pointer-to-member to private data, and that pointer-to-member
is then used from the outside to access the private data, that's
perfectly fine in current C++.

Jens

Received on 2024-11-14 21:51:53