Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
equal_to.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_EQUAL_TO_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_EQUAL_TO_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
16
17namespace std {
18
19/// @brief Function object that can be invoked for equality comparisons
20/// @tparam T The type of the values
21/// @note This class contains the member types @c result_type, @c first_argument type, and @c second_argument type.
22/// These aliases have been deprecated in C++17 and removed in C++20.
23template <class T = void>
24class equal_to {
25 public:
26 /// @brief Result type of invoking this object
27 using result_type = bool;
28 /// @brief Type of the first value to compare
30 /// @brief Type of the second value to compare
32
33 /// @brief Returns if two values are equal
34 /// @param lhs The first value to compare
35 /// @param rhs The second value to compare
36 /// @return Returns the boolean result of invoking @c operator== on @c lhs and @c rhs
37 constexpr auto operator()(T const& lhs, T const& rhs) const noexcept(noexcept(lhs == rhs)) -> bool {
38 // parasoft-begin-suppress AUTOSAR-M6_2_2-a "The type being compared is up to the user"
39 return lhs == rhs;
40 // parasoft-end-suppress AUTOSAR-M6_2_2-a "The type being compared is up to the user"
41 }
42};
43
44// parasoft-begin-suppress AUTOSAR-A2_10_1-e "False positive: 'equal_to' does not hide anything"
45// parasoft-begin-suppress AUTOSAR-A2_7_3-a "False positive: there is a comment with @brief"
46/// @brief Function object that can be invoked for equality comparisons, specialized for type deduction
47template <>
48class equal_to<void> {
49 // parasoft-end-suppress AUTOSAR-A2_7_3-a
50 public:
51 // parasoft-begin-suppress AUTOSAR-A2_10_1-e "False positive: 'is_transparent' does not hide anything"
52 /// @brief Denotes that this is a transparent function object type
53 using is_transparent = void;
54 // parasoft-end-suppress AUTOSAR-A2_10_1-e
55
56 // parasoft-begin-suppress AUTOSAR-M6_2_2-a "The type being compared is up to the user"
58 ARENE_IGNORE_ALL("-Wfloat-equal", "The type being compared is up to the user");
59 ARENE_IGNORE_CLANG("-Wimplicit-int-float-conversion", "The type being compared is up to the user");
60 ARENE_IGNORE_GCC("-Wconversion", "The type being compared is up to the user");
61 /// @brief Returns if two values are equal with parameter and return type deduced
62 /// @tparam T The type of the first value
63 /// @tparam U The type of the second value
64 /// @param lhs The first value to compare
65 /// @param rhs The second value to compare
66 /// @return Returns the result of invoking @c operator== on @c lhs and @c rhs
67 template <class T, class U>
68 constexpr auto operator()(T&& lhs, U&& rhs) const noexcept(noexcept(std::forward<T>(lhs) == std::forward<U>(rhs)))
69 -> decltype(std::forward<T>(lhs) == std::forward<U>(rhs)) {
70 return std::forward<T>(lhs) == std::forward<U>(rhs);
71 }
73 // parasoft-end-suppress AUTOSAR-M6_2_2-a "The type being compared is up to the user"
74};
75// parasoft-end-suppress AUTOSAR-A2_10_1-e
76
77} // namespace std
78
79#endif // INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_EQUAL_TO_HPP_
ARENE_IGNORE_ALL("-Wfloat-equal", "The type being compared is up to the user")
constexpr auto operator()(T &&lhs, U &&rhs) const noexcept(noexcept(std::forward< T >(lhs)==std::forward< U >(rhs))) ->
Returns if two values are equal with parameter and return type deduced.
Definition equal_to.hpp:68
ARENE_IGNORE_CLANG("-Wimplicit-int-float-conversion", "The type being compared is up to the user")
void is_transparent
Denotes that this is a transparent function object type.
Definition equal_to.hpp:53
ARENE_IGNORE_GCC("-Wconversion", "The type being compared is up to the user")
Function object that can be invoked for equality comparisons.
Definition equal_to.hpp:24
T second_argument_type
Type of the second value to compare.
Definition equal_to.hpp:31
constexpr auto operator()(T const &lhs, T const &rhs) const noexcept(noexcept(lhs==rhs)) -> bool
Returns if two values are equal.
Definition equal_to.hpp:37
bool result_type
Result type of invoking this object.
Definition equal_to.hpp:27
T first_argument_type
Type of the first value to compare.
Definition equal_to.hpp:29
Provides macros used to disable and enable compiler specific diagnostics using the _Pragma operator.
#define ARENE_IGNORE_END()
Ends a region of a suppressed diagnostic.
Definition diagnostics.hpp:136
#define ARENE_IGNORE_START()
Begins a region of a suppressed diagnostic.
Definition diagnostics.hpp:131
STL namespace.
constexpr auto forward(remove_reference_t< T > &value) noexcept -> T &&
Cast a value to an rvalue if T is an rvalue or rvalue reference, otherwise forward an lvalue referenc...
Definition forward.hpp:24