iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
std_chrono_support.hpp
Go to the documentation of this file.
1// Copyright (c) 2023 by Apex.AI Inc. All rights reserved.
2// Copyright (c) 2025 Contributors to the Eclipse Foundation
3//
4// See the NOTICE file(s) distributed with this work for additional
5// information regarding copyright ownership.
6//
7// This program and the accompanying materials are made available under the
8// terms of the Apache Software License 2.0 which is available at
9// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
10// which is available at https://opensource.org/licenses/MIT.
11//
12// SPDX-License-Identifier: Apache-2.0 OR MIT
13
14#ifndef IOX2_BB_STD_CHRONO_SUPPORT_HPP
15#define IOX2_BB_STD_CHRONO_SUPPORT_HPP
16
17#include "iox2/bb/duration.hpp"
18#include "iox2/bb/into.hpp"
19
20#include <chrono>
21
22namespace iox2 {
23namespace bb {
27template <>
28struct From<std::chrono::nanoseconds, Duration> {
29 static constexpr auto from(const std::chrono::nanoseconds& value) noexcept -> Duration {
30 return Duration::from_nanos(value.count());
31 }
32};
33
37template <>
38struct From<std::chrono::microseconds, Duration> {
39 static constexpr auto from(const std::chrono::microseconds& value) noexcept -> Duration {
40 return Duration::from_micros(value.count());
41 }
42};
43
47template <>
48struct From<std::chrono::milliseconds, Duration> {
49 static constexpr auto from(const std::chrono::milliseconds& value) noexcept -> Duration {
50 return Duration::from_millis(value.count());
51 }
52};
53
57template <>
58struct From<std::chrono::seconds, Duration> {
59 static constexpr auto from(const std::chrono::seconds& value) noexcept -> Duration {
60 return Duration::from_secs(value.count());
61 }
62};
63
64} // namespace bb
65} // namespace iox2
66
67
68#endif // IOX2_BB_STD_CHRONO_SUPPORT_HPP
static constexpr auto from_millis(T value) noexcept -> Duration
Constructs a new Duration object from milliseconds.
Definition duration.hpp:450
static constexpr auto from_secs(T value) noexcept -> Duration
Constructs a new Duration object from seconds.
Definition duration.hpp:458
static constexpr auto from_micros(T value) noexcept -> Duration
Constructs a new Duration object from microseconds.
Definition duration.hpp:442
static constexpr auto from_nanos(T value) noexcept -> Duration
Constructs a new Duration object from nanoseconds.
Definition duration.hpp:435
static constexpr auto from(const std::chrono::microseconds &value) noexcept -> Duration
static constexpr auto from(const std::chrono::milliseconds &value) noexcept -> Duration
static constexpr auto from(const std::chrono::nanoseconds &value) noexcept -> Duration
static constexpr auto from(const std::chrono::seconds &value) noexcept -> Duration