[Development] Copying a struct the easy (perhaps too easy) way

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Sat Sep 16 01:55:16 CEST 2023


Wrong mailing list?

Il 16/09/23 01:41, Henry Skoglund ha scritto:
> S a;
> S b = a.clone();
> 
> it seems to work like a charm (6.5.2 on Linux and the Mac. 5.15.2 on
> Windows) but my question is if it's kosher?

You class has value semantics, so:

S b = a;


> I have bad memories from my MFC days in the previous century doing this
> simple cloning but maybe it's considered good code now...

Many types in MFC has value semantics as well (CString, COleDateTime, etc.).


-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4244 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20230916/e61581da/attachment-0001.bin>


More information about the Development mailing list