std::chrono::treat_as_floating_point

Defined in header <chrono> template <class Rep> struct treat_as_floating_point : std::is_floating_point<Rep> {}; (since C++11) The std::chrono::treat_as_floating_point trait helps determine if a duration can be converted to another duration with a different tick period. Implicit conversions between two durations normally depends on the tick period of the durations. However, implicit conversions can happen regardless of tick period if std::chrono::treat_as_float

std::chrono::time_point_cast

template <class ToDuration, class Clock, class Duration> time_point<Clock, ToDuration> time_point_cast( const time_point<Clock, Duration> &t); (since C++11) (until C++14) template <class ToDuration, class Clock, class Duration> constexpr time_point<Clock, ToDuration> time_point_cast( const time_point<Clock, Duration> &t); (since C++14) Converts a std::chrono::time_point fr

std::chrono::time_point::time_since_epoch

duration time_since_epoch() const; (since C++11) (until C++14) constexpr duration time_since_epoch() const; (since C++14) Returns a duration representing the amount of time between *this and the clock's epoch. Parameters (none). Return value The amount of time between this time_point and the clock's epoch. Example #include <iostream> #include <chrono> #include <ctime> int main() { std::chrono::time_point<std::chrono::system_clock> p1, p2, p

std::chrono::time_point::time_point

(1) time_point(); (since C++11) (until C++14) constexpr time_point(); (since C++14) (2) explicit time_point( const duration& d ); (since C++11) (until C++14) constexpr explicit time_point( const duration& d ); (since C++14) (3) template< class Duration2 > time_point( const time_point<Clock,Duration2>& t ); (since C++11) (until C++14) template< class Duration2 > constexpr time_point( const time_point<Clock,Duration2>& t );

std::chrono::time_point::operators (operator-)

time_point& operator+=( const duration& d ); (1) (since C++11) time_point& operator-=( const duration& d ); (2) (since C++11) Modifies the time point by the given duration. 1) Applies the offset d to pt. Effectively, d is added to the internally stored duration d_ as d_ += d. 2) Applies the offset d to pt in negative direction. Effectively, d is subtracted from internally stored duration d_ as d_ -= d. Parameters d - a time offset to apply Return val

std::chrono::time_point::min

static constexpr time_point min(); Returns a time_point with the smallest possible duration, i.e. std::chrono::time_point(std::chrono::duration::min()). Parameters (none). Return value the smallest possible time_point. Example

std::chrono::time_point::max

static constexpr time_point max(); Returns a time_point with the largest possible duration, i.e. std::chrono::time_point(std::chrono::duration::max()). Parameters (none). Return value the largest possible time_point. Example #include <chrono> #include <vector> #include <iostream> int main() { std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now(); std::vector<std::chrono::time_point<std::chron

std::chrono::time_point

Defined in header <chrono> template< class Clock, class Duration = typename Clock::duration > class time_point; (since C++11) Class template std::chrono::time_point represents a point in time. It is implemented as if it stores a value of type Duration indicating the time interval from the start of the Clock's epoch. Member types Member type Definition clock Clock, the clock on which this time point is measured duration Duration, a std::chrono:

std::chrono::system_clock::to_time_t

static std::time_t to_time_t( const time_point& t ); (since C++11) Converts t to a std::time_t type. If std::time_t has lower precision, it is implementation-defined whether the value is rounded or truncated. Parameters t - system clock time point to convert Return value A std::time_t value representing t. Exceptions noexcept specification: noexcept See also from_time_t [static] converts std::time_t to a system clock time point (public static member funct

std::chrono::system_clock::now

static std::chrono::time_point<std::chrono::system_clock> now(); (since C++11) Returns a time point representing the current point in time. Parameters (none). Return value A time point representing the current time. Exceptions noexcept specification: noexcept Example #include <iostream> #include <vector> #include <numeric> #include <chrono> volatile int sink; int main() { for (auto size = 1ull; size < 1000000000ull; size *= 100) {