Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
logical_or.hpp
Go to the documentation of this file.
1// Copyright 2026, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#ifndef INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_LOGICAL_OR_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_LOGICAL_OR_HPP_
7
8// parasoft-begin-suppress CERT_CPP-DCL58-a-2 "Part of a standard library implementation"
9// parasoft-begin-suppress AUTOSAR-A17_6_1-a-2 "Part of a standard library implementation"
10
11// IWYU pragma: private, include <functional>
12// IWYU pragma: friend "stdlib_detail/.*"
13
14#include "arene/base/compiler_support/diagnostics.hpp"
15#include "stdlib/include/stdlib_detail/declval.hpp"
16#include "stdlib/include/stdlib_detail/forward.hpp"
17#include "stdlib/include/stdlib_detail/is_fundamental.hpp"
18#include "stdlib/include/stdlib_detail/void_t.hpp"
19
20namespace std {
21
22/// @brief Function object for performing logical OR (logical disjunction). Effectively calls @c operator|| on type @c
23/// T.
24/// @tparam T The type of the values.
25/// @note This class contains the member types @c result_type, @c first_argument type, and @c second_argument type.
26/// These aliases have been deprecated in C++17 and removed in C++20.
27template <class T = void>
29 public:
30 /// @brief Result type of invoking this object (deprecated in C++17)(removed in C++20)
31 using result_type = bool;
32 /// @brief Type of the first value to logically OR (deprecated in C++17)(removed in C++20)
33 using first_argument_type = T;
34 /// @brief Type of the second value to logically OR (deprecated in C++17)(removed in C++20)
35 using second_argument_type = T;
36
38 ARENE_IGNORE_ARMCLANG("-Wnull-conversion", "The standard expects the conversions here");
39 /// @brief Returns the logical OR of @c lhs and @c rhs.
40 /// @tparam U Template parameter to enable constraints.
41 /// @param lhs The first value to compute logical OR of
42 /// @param rhs The second value to compute logical OR of
43 /// @return Returns the result of invoking <c>lhs || rhs</c>.
44 constexpr auto operator()(T const& lhs, T const& rhs) const //
45 noexcept(noexcept(std::declval<T const&>() || std::declval<T const&>())) //
46 -> bool {
47 // parasoft-begin-suppress AUTOSAR-M5_3_1-a "False positive: operator|| accepts non-bool types in std::logical_or"
48 return lhs || rhs;
49 // parasoft-end-suppress AUTOSAR-M5_3_1-a
50 }
52};
53
54/// @brief Function object for performing logical OR (logical conjunction), specialized for deduction of parameter and
55/// return type.
56template <>
57class logical_or<void> {
58 public:
59 /// @brief Denotes that this is a transparent function object type
60 using is_transparent = void;
61
63 ARENE_IGNORE_ARMCLANG("-Wnull-conversion", "The standard expects the conversions here");
64 // parasoft-begin-suppress AUTOSAR-M5_0_4-a "Function return type is specified by the C++ Standard"
65 /// @brief Returns the logical OR of @c lhs and @c rhs.
66 /// @tparam T The type of @c lhs
67 /// @tparam U The type of @c rhs
68 /// @param lhs The first value to compute logical OR of
69 /// @param rhs The second value to compute logical OR of
70 /// @return Returns the result of invoking <c>lhs || rhs</c>.
71 template <class T, class U>
72 constexpr auto operator()(T&& lhs, U&& rhs) const //
73 noexcept(noexcept(std::declval<T&&>() || std::declval<U&&>())) //
74 -> decltype(std::declval<T&&>() || std::declval<U&&>()) {
75 // parasoft-begin-suppress AUTOSAR-M5_3_1-a "False positive: operator|| accepts non-bool types in std::logical_or"
76 return std::forward<T>(lhs) || std::forward<U>(rhs);
77 // parasoft-end-suppress AUTOSAR-M5_3_1-a
78 }
79 // parasoft-end-suppress AUTOSAR-M5_0_4-a
81};
82
83} // namespace std
84
85#endif // INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_LOGICAL_OR_HPP_
constexpr auto operator()(T &&lhs, U &&rhs) const noexcept(noexcept(std::declval< T && >()||std::declval< U && >())) ->
Returns the logical OR of lhs and rhs.
Definition logical_or.hpp:72
ARENE_IGNORE_ARMCLANG("-Wnull-conversion", "The standard expects the conversions here")
Function object for performing logical OR (logical disjunction). Effectively calls operator|| on type...
Definition logical_or.hpp:28
constexpr auto operator()(T const &lhs, T const &rhs) const noexcept(noexcept(std::declval< T const & >()||std::declval< T const & >())) -> bool
Returns the logical OR of lhs and rhs.
Definition logical_or.hpp:44
ARENE_IGNORE_ARMCLANG("-Wnull-conversion", "The standard expects the conversions here")
constexpr auto operator()(::arene::base::result< void, E > const &value) const noexcept(noexcept(hash< E >{}(std::declval< E const & >()))) -> std::size_t
Calculate the hash of a result.
Definition result.hpp:1827