C++ Logo


Advanced search

Re: [std-proposals] Real World Programming, private = public

From: Lénárd Szolnoki <cpp_at_[hidden]>
Date: Sat, 02 Sep 2023 06:45:12 +0100
On 2 September 2023 00:07:47 BST, Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]> wrote:
>On Sat, Sep 2, 2023 at 12:00 AM sasho648 wrote:
>> What is there to standardise - it's working as it's in my opinion. Why do you think it won't work with another compiler?
>Three problems:
>(1) If you do "#define private public" before including a header file,
>then it affects every class in that header file.
>(2) You can break SFINAE if a previously inaccessible method has
>become accessible, or if a private constructor has become public.
>(3) I don't know of any compiler on which it would cause an ABI break,
>but maybe there is one out there that would change the mangling of the
>name or the layout of the data members (or the order of function
>pointers in the Vtable).

It does affect layout on the Itanium ABI, for its definition of "POD for the purpose of layout".

There are roundabout but legal ways to work around "private" if you really have to, involving friend injection and class template instantiation. AFAIK Folly does it to get into the guts of std::vector.


>Std-Proposals mailing list

Received on 2023-09-02 05:45:19