如何使用chrono返回持续时间类型
How to return a duration type using chrono
我正在编写一个类函数,该函数使用chrono库返回以微秒为单位的持续时间。
std::chrono::duration<std::chrono::miroseconds> stop_watch::get_time() {
auto length = std::chrono::duration_cast<std::chrono::microseconds>(stop_time - start_time);
return length;
}
由于某种原因,我的编译器向我吐了。感谢所有的帮助,谢谢!
std::chrono::microseconds
stop_watch::get_time()
{
using namespace std::chrono;
return duration_cast<microseconds>(stop_time - start_time);
}
相关文章:
- 从持续时间构造std::chrono::system_clock::time_point
- 我有一个对象,它将在整个程序的持续时间内实例化,但一个类成员不会,我应该动态分配它吗?
- 标准::时间::d类型的挥发性对象
- 时间持续时间到时间字符串
- 指向(数据)成员的指针作为非类型模板参数,例如具有自动存储持续时间/无链接
- 为什么具有静态存储持续时间的同一内联变量在包含在 VS2017 编译的两个翻译单元中时会构造和销毁两次
- 将毫秒转换为给定格式的持续时间
- 具有静态存储持续时间的常量初始化变量的初始化顺序
- 划分和乘以STD :: Chrono ::持续时间
- 静态存储持续时间初始化
- C++计划持续时间内(字体)资源的分配
- 无法将 int 类型转换为时间类型(我的类类型)
- C++编译时间类型确定
- 访问和存储/解析性std :: Chrono ::持续时间:: milliseconds(cpprest)时使用什么类型
- C++ - 函数中的局部指针变量具有什么类型的存储持续时间以及它们存储在哪里?
- 运算符/ STD :: Chrono ::持续时间和自定义类型与Clang
- STD :: Min of std :: Chrono ::不同类型的持续时间
- 在时间::持续时间类型之间转换,其中两个分母的LCM都很大
- 如何使用chrono返回持续时间类型
- 引用类型和存储持续时间