C++ Logo

std-proposals

Advanced search

Re: [std-proposals] is_trivially_copyable_in_reality

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Sat, 24 Jan 2026 23:54:34 +0100
For those objects, which can be nearly memcpyed, because of some members, but not others:   I would either expect  -  the programmer creating special code for the container (manual solution) or  - the (a future) optimizer combining the code for each object with code for the bulk memcpy (automatic solution)   (Is memcpy in blocks of 8 MB really so slow?)   The use case you are creating is very specialized, meaning a language solution for it  - is complicated to use  - not clean for the abstract machine, shows to much implementation details  - So nasty, that it can lead to wrong programs: First you trivially copy a class, which is not trivially copyable and then you correct it. But in between subobjects have invalid representations. But for the correction you call back into C++. Some subobjects not meant for it will show UB.  - works anyway only for few use cases  - is perhaps not flexible enough even for those, either reducing the use cases further or making the feature more complicated for the next C++ revision after   Not a language feature.   -----Ursprüngliche Nachricht----- Von:Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]> Gesendet:Sa 24.01.2026 23:58 Betreff:Re: [std-proposals] is_trivially_copyable_in_reality An:std-proposals_at_[hidden]; CC:Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>; On Sat, Jan 24, 2026 at 9:23 PM Jason McKesson wrote: > > Sprites are not images; they *use* images. Yeah you're right I've never worked on 3D computer graphics and I'm not even really sure what a Sprite is. The sample class I gave was just an example of a class that has much more data than metadata. A better example might have been a class that contains several 512-byte RSA key pairs. Anyway my argument still stands:  The 'memcpy' optimisation for copy-construction should be usable for polymorphic types (so long as A: the class is final, or B: we're guaranteed to be dealing with the most-derived object). -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2026-01-24 23:10:52