std::chrono::time_point<Clock,Duration>::min

From cppreference.com
< cpp‎ | chrono‎ | time point
 
 
Utilities library
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

Elementary string conversions
(C++17)
(C++17)
 
Date and time utilities
(C++11)
(C++11)
Time of day
(C++20)



(C++20)(C++20)(C++20)(C++20)
Clocks
(C++20)
                                             
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
Calendars
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
Time zones
(C++20)
(C++20)
(C++20)
(C++20)
C-style date and time
 
 
static constexpr time_point min();
(until C++20)
static constexpr time_point min() noexcept;
(since C++20)

Returns a time_point with the smallest possible duration, i.e. time_point(std::chrono::duration::min()).

Parameters

(none)

Return value

the smallest possible time_point

Example

#include <iostream>
#include <ratio>
#include <chrono>
 
constexpr auto steady_min = std::chrono::steady_clock::time_point::min();
 
int main()
{
    auto last_frame = steady_min;
    std::chrono::duration<float, std::milli> game_time {0.0F};
 
    for (std::size_t count = 0; count < 5; ++count) {
        auto current_frame = std::chrono::steady_clock::now();
        // initialize timer if first frame ever:
        if (last_frame == steady_min)
            last_frame = current_frame;
        game_time += current_frame - last_frame;
        std::cout << "Drawing frame at " << game_time.count() << " ms\n";
        // animate frame at time offset game_time ...
    }
}

Possible output:

Drawing frame at 0 ms
Drawing frame at 0.17551 ms
Drawing frame at 0.358325 ms
Drawing frame at 0.545384 ms
Drawing frame at 0.736717 ms