public static member function
<chrono>

std::chrono::duration::zero

static constexpr duration zero();
Zero value
Returns a duration value of zero.

The function calls duration_value::zero to obtain the zero value for its internal count object:
1
2
3
static constexpr duration zero() {
  return duration_values<rep>::zero();
}

Parameters

none.

Return value

A duration object with a value of zero.

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
// duration::zero
#include <iostream>
#include <chrono>

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

  steady_clock::time_point t1 = steady_clock::now();

  std::cout << "Printing out something...\n";

  steady_clock::time_point t2 = steady_clock::now();

  steady_clock::duration d = t2 - t1;

  if ( d == steady_clock::duration::zero() )
    std::cout << "The internal clock did not tick.\n";

  else
    std::cout << "The internal clock advanced " << d.count() << " periods.\n";

  return 0;
}
Possible output:
Printing out something...
The internal clock did not tick.


See also