tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
time_point_cast.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_CHRONO_TIME_POINT_CAST_HPP
4#define TETL_CHRONO_TIME_POINT_CAST_HPP
5
8
9namespace etl::chrono {
10
12template <typename ToDuration, typename Clock, typename Duration>
13 requires(detail::is_duration_v<ToDuration>)
14[[nodiscard]] constexpr auto time_point_cast(time_point<Clock, Duration> const& tp) -> ToDuration
15{
16 using time_point_t = time_point<Clock, ToDuration>;
17 return time_point_t(duration_cast<ToDuration>(tp.time_since_epoch()));
18}
19
20} // namespace etl::chrono
21
22#endif // TETL_CHRONO_TIME_POINT_CAST_HPP
constexpr auto time_point_cast(time_point< Clock, Duration > const &tp) -> ToDuration
Definition time_point_cast.hpp:14
constexpr auto duration_cast(duration< Rep, Period > const &duration) noexcept(is_arithmetic_v< Rep > and is_arithmetic_v< typename ToDur::rep >) -> ToDur
Converts a duration to a duration of different type ToDur.
Definition duration_cast.hpp:77
Definition abs.hpp:11
Class template time_point represents a point in time. It is implemented as if it stores a value of ty...
Definition time_point.hpp:21
constexpr auto time_since_epoch() const noexcept -> duration
Returns a duration representing the amount of time between *this and the clock's epoch.
Definition time_point.hpp:61