4#ifndef TETL_CHRONO_ROUND_HPP
5#define TETL_CHRONO_ROUND_HPP
7#include <etl/_chrono/duration_cast.hpp>
8#include <etl/_chrono/time_point_cast.hpp>
9#include <etl/_type_traits/is_arithmetic.hpp>
14template <
typename To,
typename Rep,
typename Period>
15 requires(detail::is_duration_v<To>)
16[[nodiscard]]
constexpr auto
19 auto const low = floor<To>(dur);
20 auto const high = low + To{1};
21 auto const lowDiff = dur - low;
22 auto const highDiff = high - dur;
23 if (lowDiff < highDiff) {
26 if (lowDiff > highDiff) {
29 return low.count() & 1 ? high : low;
33template <
typename To,
typename Clock,
typename Duration>
34 requires(detail::is_duration_v<To>)
37 return time_point<Clock, To>{round<To>(tp.time_since_epoch())};
constexpr auto round(duration< Rep, Period > const &dur) noexcept(is_arithmetic_v< Rep > and is_arithmetic_v< typename To::rep >) -> To
Definition round.hpp:17
constexpr auto round(time_point< Clock, Duration > const &tp) -> time_point< Clock, To >
Definition round.hpp:35
Definition adjacent_find.hpp:9
Class template etl::chrono::duration represents a time interval.
Definition duration.hpp:32
Class template time_point represents a point in time. It is implemented as if it stores a value of ty...
Definition time_point.hpp:22