Share via


time_point Class

 

The latest version of this topic can be found at time_point Class.

A time_point describes a type that represents a point in time. It holds an object of type duration that stores the elapsed time since the epoch that is represented by the template argument Clock.

Syntax

template <class Clock,  
    class Duration = typename Clock::duration>  
class time_point;  

Members

Public Typedefs

Name Description
time_point::clock Synonym for the template parameter Clock.
time_point::duration Synonym for the template parameter Duration.
time_point::period Synonym for the nested type name duration::period.
time_point::rep Synonym for the nested type name duration::rep.

Public Constructors

Name Description
time_point::time_point Constructor Constructs a time_point object.

Public Methods

Name Description
time_point::max Method Specifies the upper limit for time_point::ref.
time_point::min Method Specifies the lower limit for time_point::ref.
time_point::time_since_epoch Method Returns the stored duration value.

Public Operators

Name Description
time_point::operator+= Adds a specified value to the stored duration.
time_point::operator-= Subtracts a specified value from the stored duration.

Requirements

Header: chrono

Namespace: std::chrono

time_point::max Method

Static method that returns the upper bound for values of type time_point::ref.

static constexpr time_point max();

Return Value

In effect, returns time_point(duration::max()).

time_point::min Method

Static method that returns the lower bound for values of type time_point::ref.

static constexpr time_point min();

Return Value

In effect, returns time_point(duration::min()).

time_point::operator+=

Adds a specified value to the stored duration value.

time_point& operator+=(const duration& Dur);

Parameters

Dur
A duration object.

Return Value

The time_point object after the addition is performed.

time_point::operator-=

Subtracts a specified value from the stored duration value.

time_point& operator-=(const duration& Dur);

Parameters

Dur
A duration object.

Return Value

The time_point object after the subtraction is performed.

time_point::time_point Constructor

Constructs a time_point object.

constexpr time_point();

constexpr explicit time_point(const duration& Dur);

template <class Duration2>  
constexpr time_point(const time_point<clock, Duration2>& Tp);

Parameters

Dur
A duration object.

Tp
A time_point object.

Remarks

The first constructor constructs an object whose stored duration value is equal to duration::zero.

The second constructor constructs an object whose stored duration value is equal to Dur. Unless is_convertible<Duration2, duration>holds true, the second constructor does not participate in overload resolution. For more information, see <type_traits>.

The third constructor initializes its duration value by using Tp.time_since_epoch().

time_point::time_since_epoch Method

Retrieves the stored duration value.

constexpr duration time_since_epoch() const;

See Also

Header Files Reference
<chrono>