1

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).

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

4

1 回答 1

8

C++11 标准的第 20.11.7.2 节定义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()应该是noexcept,这不是文档中的错误。似乎 cppreference 也这么说

于 2013-08-07T16:56:17.360 回答