std::chrono::floor(std::chrono::time_point) (3) - Linux Manuals

std::chrono::floor(std::chrono::time_point): std::chrono::floor(std::chrono::time_point)

NAME

std::chrono::floor(std::chrono::time_point) - std::chrono::floor(std::chrono::time_point)

Synopsis


Defined in header <chrono>
template <class ToDuration, class Clock, class Duration> (since C++17)
constexpr time_point<Clock, ToDuration> floor(const time_point<Clock, Duration>& tp);


Returns the largest time point t representable in ToDuration that is smaller or equal to tp.
The function does not participate in the overload resolution unless ToDuration is an specialization of std::chrono::duration.

Parameters


tp - time point to round down

Return value


d rounded down to a the next time point using duration of type ToDuration.

Possible implementation


  template <class T> struct is_duration : std::false_type {};
  template <class Rep, class Period> struct is_duration<
      std::chrono::duration<Rep, Period>> : std::true_type {};


  template <class To, class Clock, class FromDuration,
            class = std::enable_if_t<is_duration<To>{}>>
  constexpr std::chrono::time_point<Clock, To>
      floor(const std::chrono::time_point<Clock, FromDuration>& tp)
  {
      return std::chrono::time_point<Clock, To>{
          std::chrono::floor<To>(tp.time_since_epoch())};
  }

Example


 This section is incomplete
 Reason: no example

See also


                               converts a time point to another time point on the same clock, with a different duration
time_point_cast (function template)


ceil(std::chrono::time_point) converts a time_point to another, rounding up
                               (function template)
(C++17)


round(std::chrono::time_point) converts a time_point to another, rounding to nearest, ties to even
                               (function template)
(C++17)


floor(std::chrono::duration) converts a duration to another, rounding down
                               (function template)
(C++17)


floor
floorf
floorl nearest integer not greater than the given value
                               (function)


(C++11)
(C++11)