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// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_CHRONO_TIME_POINT_CAST_HPP
5#define TETL_CHRONO_TIME_POINT_CAST_HPP
6
7#include <etl/_chrono/duration_cast.hpp>
8#include <etl/_chrono/time_point.hpp>
9
10namespace etl::chrono {
11
12/// \ingroup chrono
13template <typename ToDuration, typename Clock, typename Duration>
14 requires(detail::is_duration_v<ToDuration>)
15[[nodiscard]] constexpr auto time_point_cast(time_point<Clock, Duration> const& tp) -> ToDuration
16{
17 using time_point_t = time_point<Clock, ToDuration>;
18 return time_point_t(duration_cast<ToDuration>(tp.time_since_epoch()));
19}
20
21} // namespace etl::chrono
22
23#endif // TETL_CHRONO_TIME_POINT_CAST_HPP
constexpr auto time_point_cast(time_point< Clock, Duration > const &tp) -> ToDuration
Definition time_point_cast.hpp:15
Definition abs.hpp:12
Definition adjacent_find.hpp:9
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