应该std :: chrono :: steady_clock ::现在是noexcept? [英] Should std::chrono::steady_clock::now be noexcept?

查看:213
本文介绍了应该std :: chrono :: steady_clock ::现在是noexcept?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到 std :: chrono :: steady_clock :: now noexcept cplusplus.com 上的文档。但是,我没有找到任何规定,在最新的C ++ 11草案(不幸的是我没有标准的副本)。

I've noticed that std::chrono::steady_clock::now has the noexcept specifier in the documentation at cplusplus.com. However, I haven't found any provision for this in the latest C++11 draft (unfortunately I don't have a copy of the standard).

在cplusplus.com文档中的错误或应该 noexcept 说明符的 std :: chrono :: steady_clock :: now

Is it a mistake in the cplusplus.com documenation or should std::chrono::steady_clock::now have the noexcept specifier?

推荐答案

§20.11.7.2的C ++ 11标准的定义 steady_clock

§ 20.11.7.2 of the C++11 standard's definition of steady_clock:

class steady_clock {
public:
    typedef unspecified rep;
    typedef ratio<unspecified , unspecified > period;
    typedef chrono::duration<rep, period> duration;
    typedef chrono::time_point<unspecified, duration> time_point;
    static const bool is_steady = true;
    static time_point now() noexcept;
};

所以是的, std :: steady_clock :: now c $ c>应该是 noexcept ,它不是文档中的错误。 它似乎cppreference说同样

So yes, std::steady_clock::now() should be noexcept and it isn't an error in the documentation. It seems cppreference says the same.

这篇关于应该std :: chrono :: steady_clock ::现在是noexcept?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆