Share via


system_clock Structure

Represents a clock type that is based on the real-time clock of the system.

struct system_clock;

Remarks

A clock type is used to obtain the current time. The type embodies an instantiation of duration and the class template time_point, and defines a static member function now() that returns the time.

A clock is monotonic if the value that is returned by a first call to now() is always less than or equal to the value that is returned by a subsequent call to now().

A clock is steady if it is monotonic and if the time between clock ticks is constant.

In this implementation, a system_clock is synonymous with a high_resolution_clock.

Members

Public Typedefs

Name

Description

system_clock::duration

A synonym for duration<rep, period>.

system_clock::period

A synonym for the type that is used to represent the tick period in the contained instantiation of duration.

system_clock::rep

A synonym for the type that is used to represent the number of clock ticks in the contained instantiation of duration.

system_clock::time_point

A synonym for time_point<Clock, duration>, where Clock is a synonym for either the clock type itself or another clock type that is based on the same epoch and has the same nested duration type.

Public Methods

Name

Description

system_clock::from_time_t Method

Static. Returns a time_point that most closely approximates a specified time.

system_clock::now Method

Static. Returns the current time.

system_clock::to_time_t Method

Static. Returns a time_t object that most closely approximates a specified time_point.

Public Constants

Name

Description

system_clock::is_monotonic Constant

Specifies whether the clock type is monotonic.

system_clock::is_steady Constant

Specifies whether the clock type is steady.

Requirements

Header: chrono

Namespace: std::chrono

See Also

Reference

<chrono>

steady_clock Class

Other Resources

C++ Standard Library Header Files