Consider the following code (LWS):
#include <iostream>
#include <chrono>
inline void test(
const std::chrono::high_resolution_clock::time_point& first,
const std::chrono::high_resolution_clock::time_point& second)
{
std::cout << first.time_since_epoch().count() << std::endl;
std::cout << second.time_since_epoch().count() << std::endl;
}
int main(int argc, char* argv[])
{
test(std::chrono::high_resolution_clock::now(),
std::chrono::high_resolution_clock::now());
return 0;
}
You have to run it several times because sometimes, there is no visible difference. But when there is a visible difference between the time of evaluation of first
and second
, the result is the following under g++ :
1363376239363175
1363376239363174
and the following under intel and clang :
1363376267971435
1363376267971436
It means that under g++, the second
argument is evaluated first, and under intel and clang the first
argument is evaluated first.
Which one is true according to the C++11 standard?
Which one is true according to the C++11 standard ?
Both are permissible. To quote the standard (§8.3.6):
The order of evaluation of function arguments is unspecified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With