std::chrono::time_point<Clock,Duration>::time_point (3) - Linux Manuals
std::chrono::time_point<Clock,Duration>::time_point: std::chrono::time_point<Clock,Duration>::time_point
Command to display std::chrono::time_point<Clock,Duration>::time_point
manual in Linux: $ man 3 std::chrono::time_point<Clock,Duration>::time_point
NAME
std::chrono::time_point<Clock,Duration>::time_point - std::chrono::time_point<Clock,Duration>::time_point
Synopsis
time_point(); (since C++11)
(until C++14)
constexpr time_point(); (since C++14)
explicit time_point( const duration& d ); (since C++11)
(1) (until C++14)
constexpr explicit time_point( const duration& d ); (since C++14)
template< class Duration2 > (2) (since C++11)
time_point( const time_point<Clock,Duration2>& t ); (3) (until C++14)
template< class Duration2 > (since C++14)
constexpr time_point( const time_point<Clock,Duration2>& t );
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>
using Clock = std::chrono::high_resolution_clock;
using TimePoint = std::chrono::time_point<Clock>;
void print_ms(const TimePoint& point)
{
using Ms = std::chrono::milliseconds;
const Clock::duration since_epoch = point.time_since_epoch();
std::cout << std::chrono::duration_cast<Ms>(since_epoch).count() << " ms\n";
}
int main()
{
const TimePoint default_value = TimePoint(); // (1)
print_ms(default_value); // 0 ms
const Clock::duration duration_4_seconds = std::chrono::seconds(4);
const TimePoint time_point_4_seconds(duration_4_seconds); // (2)
// 4 seconds from start of epoch
print_ms(time_point_4_seconds); // 4000 ms
const TimePoint time_point_now = Clock::now(); // (3)
print_ms(time_point_now); // 43098276 ms
}
Possible output:
0 ms
4000 ms
43098276 ms
See also
constructs new duration
constructor (public member function of std::chrono::duration<Rep,Period>)
converts a duration to another, with a different tick interval
duration_cast (function template)
Pages related to std::chrono::time_point<Clock,Duration>::time_point
- std::chrono::time_point<Clock,Duration>::time_since_epoch (3) - std::chrono::time_point<Clock,Duration>::time_since_epoch
- std::chrono::time_point<Clock,Duration>::max (3) - std::chrono::time_point<Clock,Duration>::max
- std::chrono::time_point<Clock,Duration>::min (3) - std::chrono::time_point<Clock,Duration>::min
- std::chrono::time_point<Clock,Duration>::operator++, (3) - std::chrono::time_point<Clock,Duration>::operator++,
- std::chrono::time_point<Clock,Duration>::operator++,std::chrono::time_point<Clock,Duration>::operator-- (3) - - std::chrono::time_point<Clock,Duration>::operator++,std::chrono::time_point<Clock,Duration>::operator--
- std::chrono::time_point<Clock,Duration>::operator+,operator- (3) - - std::chrono::time_point<Clock,Duration>::operator+,operator-
- std::chrono::time_point (3) - std::chrono::time_point
- std::chrono::time_point_cast (3) - std::chrono::time_point_cast
- std::chrono::time_of_day (3) - std::chrono::time_of_day
- std::chrono::time_of_day<Duration>::hours,std::chrono::time_of_day<Duration>::minutes, (3) - std::chrono::time_of_day<Duration>::hours,std::chrono::time_of_day<Duration>::minutes,
- std::chrono::time_of_day<Duration>::make12,std::chrono::time_of_day<Duration>::make24 (3) - std::chrono::time_of_day<Duration>::make12,std::chrono::time_of_day<Duration>::make24
- std::chrono::time_of_day<Duration>::operatorprecision, (3) - std::chrono::time_of_day<Duration>::operatorprecision,
- std::chrono::time_of_day<Duration>::operatorprecision,std::chrono::time_of_day<Duration>::to_duration (3) - std::chrono::time_of_day<Duration>::operatorprecision,std::chrono::time_of_day<Duration>::to_duration
- std::chrono::time_of_day<Duration>::time_of_day (3) - std::chrono::time_of_day<Duration>::time_of_day
- std::chrono::time_zone (3) - std::chrono::time_zone
- std::chrono::time_zone::get_info (3) - std::chrono::time_zone::get_info
- std::chrono::time_zone::name (3) - std::chrono::time_zone::name
- std::chrono::time_zone::to_local (3) - std::chrono::time_zone::to_local
- std::chrono::time_zone::to_sys (3) - std::chrono::time_zone::to_sys
- std::chrono::tai_clock (3) - std::chrono::tai_clock