C++ Logo

std-proposals

Advanced search

Re: [std-proposals] is_trivially_copyable_in_reality

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Sat, 24 Jan 2026 00:14:13 +0000
On Fri, Jan 23, 2026 at 11:48 PM Frederick Virchanza Gotham wrote:
>
> That is why is_trivially_copy_constructible_v<Poly> should really be
> is_trivially_copy_constructible_v<Poly, true>. That second template
> parameter, i.e. a boolean of value 'true', indicates that you're
> dealing with the most-derived object. This should evaluate to true so
> that we can use 'memcpy'. But on Apple Silicon it would evaluate to
> false.


By the way there's no absolutely no justification for the following
GodBolt failing to compile:

    https://godbolt.org/z/a7bMxahcf

I've marked that class 'final' so there's no fear of copying the base
from a derived. Therefore no reason we can't use 'memcpy'.

And here's the GodBolt copy-pasted:

    #include <type_traits>

    class MyClass final {
        virtual void Func(void){}
    };

    static_assert( std::is_trivially_copy_constructible_v<MyClass> );

    int main(void){}

Received on 2026-01-24 00:13:19