我不明白为什么这段代码会被 g++ 4.7.2 阻塞:
#include <chrono>
main ()
{
std::chrono::system_clock::time_point t1, t2 ;
std::chrono::seconds delay ;
t1 = std::chrono::system_clock::time_point::max () ;
t2 = std::chrono::system_clock::now () ;
delay = t1 - t2 ;
// t1 = t2 + delay ;
// t1 = t2 - delay ;
}
出现错误:
test.cc: In function ‘int main()’:
test.cc:10:18: error: no match for ‘operator=’ in ‘delay = std::chrono::operator,<std::chrono::system_clock, std::chrono::duration<long int, std::ratio<1l, 1000000l> >, std::chrono::duration<long int, std::ratio<1l, 1000000l> > >((*(const std::chrono::time_point<std::chrono::system_clock, std::chrono::duration<long int, std::ratio<1l, 1000000l> > >*)(& t1)), (*(const std::chrono::time_point<std::chrono::system_clock, std::chrono::duration<long int, std::ratio<1l, 1000000l> > >*)(& t2)))’
在我看来,“time_point - time_point”给出了一个“持续时间”。