Materialization is the step by which prvalue is used to create a temporary object in memory. Temporary objects have existed since C++98, but the timing of prvalue materialization was redefined in C++17. Since C++17, prvalues do not “immediately” materialize temporary objects; materialization occurs only when a temporary object is required. In other words, C++17 defers the materialization of a prvalue “as long as possible”. [cf. class. temporary] This change guarantees copy elision.
For example:
class C{};
C create() { return C{}; }
void foo(C c){}
int main(){
foo(create());
}
By comparing these two behaviors, we can see that the advantage of deferring the materialization of prvalues is that no copy or move constructor needs to be invoked; threrfore, copy elision is guaranteed.
Please see below for more details:
How does a function return local object internally?
Name Returned Value Optimization
Avoid Unnecessary std::move()