Hi, just got the need to copy a struct so I started doing it the hard way (i.e. member by member) but on a lark I tried a simple copy from *this, say like this:

struct S
{
    int i;
    QString s;
    QDate d;
    QStringList sl;

    S clone() { return *this; }
};

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? I have bad memories from my MFC days in the previous century doing this simple cloning but maybe it's considered good code now...
Rgrds Henry

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

Reply via email to