public member function
<chrono>

std::chrono::time_point::time_point

(1)
time_point();
(2)
template <class Duration2>time_point (const time_point<clock,Duration2>& tp);
(3)
explicit time_point (const duration& dtn);
Construct time_point
Constructs a time_point object:
default constructor (1)
Constructs an object with the epoch as value.
copy / from time_point (2)
Constructs an object representing the same time point as tp.
Only called if Duration2 is implicitly convertible to the duration type of the newly constructed object.
from duration object (3)
Constructs an object representing a time point where a duration of d has elapsed since the epoch.

Parameters

tp
Another time_point object.
time_point<clock,Duration2> is a time_point type that uses the same clock and has a duration type implictly convertible to the one in the newly constructed object.
dtn
A duration object.
duration is a member type, defined as the duration type used by the object.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// time_point constructors
#include <iostream>
#include <chrono>
#include <ctime>

int main ()
{
  using namespace std::chrono;

  system_clock::time_point tp_epoch;	// epoch value

  time_point <system_clock,duration<int>> tp_seconds (duration<int>(1));

  system_clock::time_point tp (tp_seconds);

  std::cout << "1 second since system_clock epoch = ";
  std::cout << tp.time_since_epoch().count();
  std::cout << " system_clock periods." << std::endl;

  // display time_point:
  std::time_t tt = system_clock::to_time_t(tp);
  std::cout << "time_point tp is: " << ctime(&tt);

  return 0;
}

Possible output:
1 second since system_clock epoch = 1000000 system_clock periods.
time_point tp is: Thu Jan 01 01:00:01 1970


See also