Chapter 20. An Unmanaged Pointer Problem, Part 1: Parameter Evaluation

Difficulty: 6

Readers of Exceptional C++ and this book know that exception safety is anything but trivial. This Item points out an exception safety problem that was discovered fairly recently, and shows how best to avoid it in your own code.

  1. In each of the following statements, what can you say about the order of evaluation of the functions f, g, and h and the expressions expr1 and expr2? Assume that expr1 and expr2 do not contain more function calls.

    // Example 20-1(a)
    //
    f( expr1, expr2 );
    
    // Example 20-1(b)
    //
    f( g( expr1 ), h( expr2 ) );
    
  2. In your travels through the dusty corners of your company's code archives, you find the following code fragment:

     // Example 20-2 // // In ...

Get More Exceptional C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.