Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
less_equal.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_LESS_EQUAL_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_LESS_EQUAL_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 "stdlib/include/stdlib_detail/forward.hpp"
15
16namespace std {
17
18// parasoft-begin-suppress AUTOSAR-M4_5_1-a "Standard library implementation must cover all types, including bool"
19// parasoft-begin-suppress CERT_C-EXP46-b "Standard library implementation must cover all types, including bool"
20
21/// @brief Function object that can be invoked for less than or equal to comparisons
22/// @tparam T The type of the values
23/// @note This class contains the member types @c result_type, @c first_argument type, and @c second_argument type.
24/// These aliases have been deprecated in C++17 and removed in C++20.
25template <class T = void>
27 public:
28 /// @brief Result type of invoking this object
29 using result_type = bool;
30 /// @brief Type of the first value to compare
31 using first_argument_type = T;
32 /// @brief Type of the second value to compare
33 using second_argument_type = T;
34
35 /// @brief Returns if the first value is less than or equal to the second
36 /// @param lhs The first value to compare
37 /// @param rhs The second value to compare
38 /// @return Returns the boolean result of invoking @c operator<= on @c lhs and @c rhs
39 constexpr auto operator()(T const& lhs, T const& rhs) const noexcept(noexcept(lhs <= rhs)) -> bool {
40 return lhs <= rhs;
41 }
42};
43
44/// @brief Function object that can be invoked for less than or equal to comparisons, specialized for type deduction
45template <>
46class less_equal<void> {
47 public:
48 /// @brief Denotes that this is a transparent function object type
49 using is_transparent = void;
50
51 /// @brief Returns if the first value is less than or equal to the second
52 /// @tparam T The first type
53 /// @tparam U The second type
54 /// @param lhs The first value to compare
55 /// @param rhs The second value to compare
56 /// @return Returns the boolean result of invoking @c operator<= on @c lhs and @c rhs
57 template <class T, class U>
58 constexpr auto operator()(T&& lhs, U&& rhs) const noexcept(noexcept(std::forward<T>(lhs) <= std::forward<U>(rhs)))
59 -> decltype(std::forward<T>(lhs) <= std::forward<U>(rhs)) {
60 return std::forward<T>(lhs) <= std::forward<U>(rhs);
61 }
62};
63
64} // namespace std
65
66#endif // INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_LESS_EQUAL_HPP_
constexpr auto operator()(T &&lhs, U &&rhs) const noexcept(noexcept(std::forward< T >(lhs)<=std::forward< U >(rhs))) ->
Returns if the first value is less than or equal to the second.
Definition less_equal.hpp:58
Function object that can be invoked for less than or equal to comparisons.
Definition less_equal.hpp:26
constexpr auto operator()(T const &lhs, T const &rhs) const noexcept(noexcept(lhs<=rhs)) -> bool
Returns if the first value is less than or equal to the second.
Definition less_equal.hpp:39
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