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

2023-09-16 Thread Volker Hilsheimer via Development


> On 16 Sep 2023, at 02:05, Henry Skoglund  wrote:
> 
> On 2023-09-16 01:55, Giuseppe D'Angelo via Development wrote:
>> 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.).
>> 
> 
> Thanks Guiseppe and sorry if this was a kind of noob question 

Nothing wrong with asking noob questions, and designing types in C++ has not 
become less complex since MFC was made. You might want to read up about the 
rule of three/five/zero:

https://en.cppreference.com/w/cpp/language/rule_of_three

Cheers,
Volker


-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


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

2023-09-15 Thread Henry Skoglund

On 2023-09-16 01:55, Giuseppe D'Angelo via Development wrote:

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.).




Thanks Guiseppe and sorry if this was a kind of noob question 

--
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


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

2023-09-15 Thread Giuseppe D'Angelo via Development

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.dang...@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



smime.p7s
Description: Firma crittografica S/MIME
-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development