vendredi 27 mars 2020

Why return value optimization does not work when return ()

My code is as follows. Why () makes RVO fail?

A fn() {
    A a{};
    return (a); // move constructor of class A works
    return a;   // RVO works
}

int main() {
    A a = fn();
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire