在我的项目中,在升级到VS2015之前,它编译得很好。现在,我得到了与std::chrono::timepoint有关的10个错误。这些都是错误:https://gyazo.com/0d3c51cf87c49661b0f24da4a027b0d9 (图像,因为有这么多)
导致错误的代码行示例:
fStart = clock::now();引起no operator '=' matches these operands
double t = std::chrono::duration_cast<std::chrono::milliseconds>(clock::now() - fStart).count();
原因
no instance of function template 'std::chrono::duraction_cast' matches the argument list. argument types are: ( <error-type> )
(fStart是chrono::system_clock::timepoint,t显然是双重的)
如果有人想要看到这些错误,那么下面是这些错误的全部函数:
void Animation::update() {
using clock = std::chrono::high_resolution_clock;
if (animType == TYPE_MS) {
if (firstUpdate) {
fStart = clock::now();
firstUpdate = false;
}
double t = std::chrono::duration_cast<std::chrono::milliseconds>(clock::now() - fStart).count();
if (!paused) {
if (t >= frames[frame]->getTime())
advance();
}
} else if (animType == TYPE_FRAME) {
if (firstUpdate)
firstUpdate = false;
if (!paused)
fTime += speed;
if (speed < 0.0) {
if (fTime <= -frames[frame]->getTime())
advance();
} else {
if (fTime >= frames[frame]->getTime())
advance();
}
}
}我该怎么做才能修好这些?
发布于 2015-12-13 23:48:23
我建议放弃使用std::chrono::high_resolution_clock。
如果您需要跨处理器运行或进程必须稳定的time_point,请使用std::chrono::system_clock,它与民用日历有明确的关系。
否则使用std::chrono::steady_clock。这钟就像秒表。它有利于计时,但它不能告诉你当前(公民)的时间。
https://stackoverflow.com/questions/34257225
复制相似问题