I asked this question yesterday, but my thread got shut down, so I'm talking into the void. So, my code is not compiling, but I would very much like it to. Here's is my snippet:
float numSeconds = 50;
std::chrono::steady_clock::time_point startTime = std::chrono::steady_clock::now();
auto duration = std::chrono::duration<float, std::chrono::seconds>(numSeconds);
startTime -= duration;
Seems like it should be pretty straightforward, but I'm getting an operator not found error when attempting the in-place subtraction. Any suggestions? I've also tried replacing the third line with the following:
auto duration = std::chrono::duration<float, std::ratio<1, 1>>(numSeconds);
However, that line doesn't seem to be the cause of the issues, both approaches seem valid. It's my final line still that is unhappy. The error code I am getting is:
"Error C2679 binary '-=': no operator found which takes a right-hand operand of type 'std::chrono::duration<float,std::chrono::seconds>' (or there is no acceptable conversion)"
Additionally, when I change the last line to:
timer.m_startTime = timer.m_startTime - duration;
I get the following error code:
Error C2679 binary '=': no operator found which takes a right-hand operand of type 'std::chrono::time_point<std::chrono::steady_clock,std::chrono::duration<float,std::ratio<1,1000000000>>>' (or there is no acceptable conversion)
Are these somehow incompatible types? I would think that they'd resolve to the same thing.