如何修复 C++ 错误:invalid use of template-name 'std::chrono::time_point' without an argument list
问题:
你正在尝试在 C++ 代码中使用 std::chrono::time_point,但编译器抛出类似这样的错误消息
error.txt
MyClass.hpp:58:5: error: invalid use of template-name ‘std::chrono::time_point’ without an argument list
58 | std::chrono::time_point t0;解决方案
std::chrono::time_point 是一个需要两个模板参数的模板:时钟和持续时间。但是,持续时间参数默认为 Clock::duration,所以你只需显式指定时钟。
通常你可以直接使用 std::chrono::system_clock:
MyClass.hpp
std::chrono::time_point<std::chrono::system_clock> t0;Check out similar posts by category:
C/C++, GCC Errors
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow