iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
optional.hpp
Go to the documentation of this file.
1// Copyright (c) 2025 Contributors to the Eclipse Foundation
2//
3// See the NOTICE file(s) distributed with this work for additional
4// information regarding copyright ownership.
5//
6// This program and the accompanying materials are made available under the
7// terms of the Apache Software License 2.0 which is available at
8// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
9// which is available at https://opensource.org/licenses/MIT.
10//
11// SPDX-License-Identifier: Apache-2.0 OR MIT
12
13#ifndef IOX2_INCLUDE_GUARD_BB_OPTIONAL_HPP
14#define IOX2_INCLUDE_GUARD_BB_OPTIONAL_HPP
15
16#include "iox2/bb/duration.hpp"
17#include "iox2/bb/variation/optional_adaption.hpp"
18
19#include <ostream>
20
21namespace iox2 {
22namespace bb {
23
24template <typename T>
25using Optional = iox2::bb::variation::Optional<T>;
26using NulloptT = iox2::bb::variation::NulloptT;
27
28constexpr NulloptT NULLOPT = iox2::bb::variation::NULLOPT;
29
30} // namespace bb
31} // namespace iox2
32
36template <typename T>
37auto stream_operator(std::ostream& stream, const iox2::bb::Optional<T>& value) -> std::ostream& {
38 stream << "Optional { ";
39 if (value.has_value()) {
40 stream << "value: " << value.value();
41 } else {
42 stream << "NULLOPT";
43 }
44 stream << " }";
45
46 return stream;
47}
48
49#endif // IOX2_INCLUDE_GUARD_BB_OPTIONAL_HPP
constexpr NulloptT NULLOPT
Definition optional.hpp:28
iox2::bb::variation::NulloptT NulloptT
Definition optional.hpp:26
iox2::bb::variation::Optional< T > Optional
Definition optional.hpp:25
auto stream_operator(std::ostream &stream, const iox2::bb::Optional< T > &value) -> std::ostream &
Definition optional.hpp:37