Timing vs the “as-if” rule
问题 There is a great question about the "as-if" rule in general, but I wonder if there are any excpetions when it comes to measuring time. Consider this (taken from here slightly modified): using std::chrono; auto begin = steady_clock::now(); auto result = some_lengthy_calculation(some_params); auto end= std::chrono::steady_clock::now(); std::cout << "Time diff = " << duration_cast<microseconds>(end - begin).count() <<std::endl; std::cout << "Result = " << result; The compiler is allowed to apply