Page 1 of 1

Wird NRVO garantiert auf den Bau der Mitglieder einer Struktur angewendet?

Posted: 03 Apr 2025, 09:38
by Anonymous
Ich weiß, dass der Fooresult selbst direkt im Rückgabereicherspeicherort konstruiert ist. Ich vermute, dies ist wirklich nur ein Fall typischer Bewegungskonstruktion, aber gibt es Garantien dafür, dass seine Mitglieder bewegt werden?

Code: Select all

struct FooResult {
MoveConstructibleType x;
};

FooResult foo()
{
MoveConstructibleType x;
// do some stuff computing x...
return FooResult {.x = x}; // is the construction of x guaranteed to be move constructed?
}