std::chrono::time_point<Clock,Duration>::time_point - cppreference.com

From cppreference.com

time_point(); (1)(since C++11)
(constexpr since C++14)explicittime_point(constduration&d); (2)(since C++11)
(constexpr since C++14)template<classDuration2>time_point(consttime_point<Clock,Duration2>&t); (3)(since C++11)
(constexpr since C++14)Constructs a new time_point from one of several optional data sources.

1) Default constructor, creates a time_point representing the Clock's epoch (i.e.,

time_since_epoch()

is zero).

2) Constructs a time_point at Clock's epoch plus d.

3) Constructs a time_point by converting t to duration. This constructor only participates in overload resolution if Duration2 is implicitly convertible to duration.

Parameters

d - a duration to copy from t - a time_point to convert from Example

Run this code

#include<chrono>#include<iostream>usingClock=std::chrono::steady_clock;usingTimePoint=std::chrono::time_point<Clock>;voidprint_ms(constTimePoint&point){usingMs=std::chrono::milliseconds;constClock::durationsince_epoch=point.time_since_epoch();std::cout<<std::chrono::duration_cast<Ms>(since_epoch)<<'\n';}intmain(){constTimePointdefault_value=TimePoint();// (1)print_ms(default_value);// 0msconstClock::durationduration_4_seconds=std::chrono::seconds(4);constTimePointtime_point_4_seconds(duration_4_seconds);// (2)// 4 seconds from start of epochprint_ms(time_point_4_seconds);// 4000msconstTimePointtime_point_now=Clock::now();// (3)print_ms(time_point_now);// 212178842ms}Possible output:

0ms 4000ms 212178842ms See also

constructs new duration
(public member function of std::chrono::duration<Rep,Period>)

[edit]

(C++11)

converts a duration to another, with a different tick interval
(function template)

[edit]