Search⌘ K
AI Features

Expression Evaluation Order

Explore how C++17 defines a more predictable evaluation order of function arguments, ensuring each parameter is fully evaluated before the next starts. This lesson helps you understand the improvements over previous versions to avoid issues like memory leaks and enhance code safety.

Expression Evaluation: C++ Older Version

Until C++17 the language hasn’t specified any evaluation order for function parameters. Period.

For example, that’s why in C++14 make_unique is not just syntactic sugar, but it guarantees memory safety.

Let’s have a look at the following example:

foo(unique_ptr<T>(new T), otherFunction()); // first case

And without explicit new ...