January 2019
Intermediate to advanced
384 pages
11h 50m
English
Another context where temporaries could arise was in the case of constant reference parameters in function calls. As such, references would be allowed to bind to a temporary object and implicit conversion could be triggered, creating a temporary only used inside of the function:
struct T { T(int i) { ... }};void func(const T& o);main(){ func(1); // creates temporary object T! }
For that reason, the explicit annotation for constructors was introduced, which blocks such unwanted implicit conversions.
Read now
Unlock full access