C++ Logo

std-proposals

Advanced search

Re: std::parent_of_member

From: Thiago Macieira <thiago_at_[hidden]>
Date: Fri, 05 Nov 2021 18:41:58 -0700
On Friday, 5 November 2021 17:26:17 PDT Lénárd Szolnoki via Std-Proposals
wrote:
> I don't think a non-UB implementation is possible here. I have the
> impression that the pointer to the parent type is intentionally unreachable
> and in theory compilers are allowed to optimize based on that.

But that's irrelevant.

If the paper proposing such a functionality is accepted and added to
<type_traits>, *how* the implementation implements it is the implementation's
own problem. They may need to add an intrinsic or magic to make it happen, so
the compiler never accidentally mis-optimises it because it thinks it's UB.

Your use of a std functionality in a way permitted by the standard is not UB.
Copying such an implementation to your own code may be.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

Received on 2021-11-05 20:42:03