考虑以下代码(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;
}
您必须多次运行它,因为有时没有明显的区别。first
但是当和的求值时间有明显差异时,second
在 g++ 下的结果如下:
1363376239363175
1363376239363174
以及 intel 和 clang 下的以下内容:
1363376267971435
1363376267971436
这意味着在 g++ 下,second
首先评估参数,而在 intel 和 clang 下,first
首先评估参数。
根据 C++11 标准,哪一个是正确的?