iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
expected.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_EXPECTED_HPP
14#define IOX2_INCLUDE_GUARD_BB_EXPECTED_HPP
15
16#include "iox2/bb/variation/expected_adaption.hpp"
17
18namespace iox2 {
19namespace bb {
20
21template <typename T, typename E>
22using Expected = iox2::bb::variation::Expected<T, E>;
23template <typename E>
24using Unexpected = iox2::bb::variation::Unexpected<E>;
25
26using InPlaceT = iox2::bb::variation::InPlaceT;
27using UnexpectT = iox2::bb::variation::UnexpectT;
28
29constexpr InPlaceT IN_PLACE = iox2::bb::variation::IN_PLACE;
30constexpr UnexpectT UNEXPECT = iox2::bb::variation::UNEXPECT;
31
32template <typename E>
33constexpr auto err(const E& error) -> Unexpected<E> {
34 return Unexpected<E>(error);
35}
36
37template <typename E, std::enable_if_t<!std::is_lvalue_reference<E>::value, bool> = true>
38constexpr auto err(E&& error) -> Unexpected<E> {
39 return Unexpected<E>(std::forward<E>(error));
40}
41
42} // namespace bb
43} // namespace iox2
44
45#endif // IOX2_INCLUDE_GUARD_BB_EXPECTED_HPP
iox2::bb::variation::Unexpected< E > Unexpected
Definition expected.hpp:24
iox2::bb::variation::UnexpectT UnexpectT
Definition expected.hpp:27
constexpr auto err(const E &error) -> Unexpected< E >
Definition expected.hpp:33
iox2::bb::variation::InPlaceT InPlaceT
Definition expected.hpp:26
iox2::bb::variation::Expected< T, E > Expected
Definition expected.hpp:22
constexpr UnexpectT UNEXPECT
Definition expected.hpp:30
constexpr InPlaceT IN_PLACE
Definition expected.hpp:29