vitaut
vitaut

Reputation: 55685

Should std::chrono::steady_clock::now be noexcept?

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?

Upvotes: 1

Views: 412

Answers (1)

Rapptz
Rapptz

Reputation: 21317

§ 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;
};

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

Upvotes: 8

Related Questions