C++ Logo


Advanced search

Subject: Re: Pointer-interconvertibility between a standard-layout non-empty class object and its empty base class subobject
From: Kazutoshi Satoda (k_satoda_at_[hidden])
Date: 2020-12-07 20:51:55

On 2020/12/08 11:14 +0900, Richard Smith wrote:
> On Mon, 7 Dec 2020 at 17:39, Kazutoshi Satoda <k_satoda_at_[hidden]>
> wrote:
>> I found the wording was touched by CWG 2254.
>> https://wg21.cmeerw.net/cwg/issue2254
>> I think the replacement of "the first base class subobject" to
>> "any base class subobject" was OK since Empty-base-optimization is
>> mandated for standard-layout classes. But now I wonder that "if the
>> object has no non-static data members" should have been struck then.
> I think you're right, and that those words should have been struck by
> CWG2254.

Oh ... since striking that words now seems not editorial, shall I
write up CWG issue for this? (DR against C++20?)

And then I'm afraid that the new (C++20) type trait
is_pointer_interconvertible_base_of_v<B, D> is almost equivalent to
just is_standard_layout_v<D> && is_base_of_v<B, D>.
The proposal <https://wg21.link/p0466> was written at the time the
standard said "the first base class subobject". R0 was dated at
2016-10-15, and final R5 still says "an initial base":
> Delving deeper into the problem, I found another situation where a
> programmer might rely on a fact about the type system that can't be
> asserted: the pointer-interconvertiblity of an object and an initial
> base or member subobject. A simple type trait handles the base
> subobject case:
> template<class Base, class Derived>
> struct is_pointer_interconvertible_base_of;
(added CC to the author lisa.e.lippincott_at_[hidden])
I think the current definition of is_pointer_interconvertible_base_of
is not invalid, but the motivation of the addition will be questioned,

Sorry for being too late.


STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups