Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
is_compare.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_ARENE_BASE_TYPE_TRAITS_IS_COMPARE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_IS_COMPARE_HPP_
7
8// IWYU pragma: private, include "arene/base/type_traits.hpp"
9// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
10
11#include "arene/base/stdlib_choice/declval.hpp"
12#include "arene/base/stdlib_choice/enable_if.hpp"
13#include "arene/base/stdlib_choice/is_same.hpp"
14#include "arene/base/type_traits/is_binary_predicate.hpp"
15
16namespace arene {
17namespace base {
18namespace is_compare_detail {
19
20template <class F, class T1, class T2, class = void>
21extern constexpr bool is_equiv_valid_v = false;
22
23template <class F, class T1, class T2>
24extern constexpr bool is_equiv_valid_v< //
25 F,
26 T1,
27 T2,
28 std::enable_if_t< //
29 std::is_same<
30 bool,
31 decltype( //
32 !(std::declval<F>()(std::declval<T1>(), std::declval<T2>())) &&
33 !(std::declval<F>()(std::declval<T2>(), std::declval<T1>()))
34 )>::value> //
35 > = true;
36
37} // namespace is_compare_detail
38
39/// @brief determines if a type satisfies the Compare named requirement
40/// @tparam F the possible compare function object
41/// @tparam T1 type of the first argument
42/// @tparam T2 type of the second argument
43///
44/// Compare is a set of requirements expected by some of the standard library
45/// facilities from the user-provided function object types.
46///
47/// The return value of the function call operation applied to an object of a
48/// type satisfying Compare, when converted to bool, yields true if the first
49/// argument of the call appears before the second in the strict weak ordering
50/// relation induced by this type, and false otherwise.
51///
52/// As with any BinaryPredicate, evaluation of that expression is not allowed to
53/// call non-const functions through the dereferenced iterators and,
54/// syntactically, the function call operation must accept const object
55/// arguments, with the same behavior regardless of whether the arguments are
56/// const or non-const.
57///
58/// A type satisfies Compare if
59/// * the type satisfies BinaryPredicate and
60/// Given @c comp, an object of type @c F and <c> equiv(a, b) </c>, an
61/// expression-equivalent to <c> !comp(a, b) && !comp(b, a) </c>,
62/// the following expressions must be valid and have their specified effects:
63/// * <c>comp(a, b)</c> establishes a strict weak ordering
64/// * <c>equiv(a, b)</c> establishes an equivalence relationship
65///
66/// @{
67template <class F, class T1, class T2 = T1>
68extern constexpr bool is_compare_v = //
72/// @}
73
74} // namespace base
75} // namespace arene
76#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_IS_COMPARE_HPP_
Definition array_exceptions_disabled.cpp:11
constexpr bool is_compare_v
determines if a type satisfies the Compare named requirement
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10