Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
is_binary_predicate.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_BINARY_PREDICATE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_IS_BINARY_PREDICATE_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/add_lvalue_reference.hpp"
12#include "arene/base/stdlib_choice/is_copy_constructible.hpp"
13#include "arene/base/stdlib_choice/is_move_constructible.hpp"
16// IWYU pragma: no_include "arene/base/stdlib_choice/remove_cv.hpp"
17// IWYU pragma: no_include "arene/base/stdlib_choice/remove_reference.hpp"
18
19namespace arene {
20namespace base {
21
22/// @brief determines if a type satisfies the BinaryPredicate named requirement
23/// @tparam F the possible binary predicate function object
24/// @tparam T1 type of the first argument
25/// @tparam T2 type of the second argument
26///
27/// BinaryPredicate is a set of requirements expected by some of the standard
28/// library facilities from the user-provided function object types.
29///
30/// Given a BinaryPredicate @c pred and a pair of iterators @c iter1 and
31/// @c iter2 or an iterator @c iter and a (possibly const) value @c value, the
32/// type and value category of the expression <c> pred(*iter1, *iter2) </c> or,
33/// respectively, <c> pred(*iter, value) </c>, must meet the BooleanTestable
34/// requirements.
35///
36/// In addition, evaluation of that expression is not allowed to call non-const
37/// member functions of the dereferenced iterators; syntactically, the predicate
38/// must accept const object arguments, with the same behavior regardless of
39/// whether its arguments are const or non-const.
40///
41/// A type satisfies BinaryPredicate if
42/// * the type satisfies Predicate
43/// * the type satisfies CopyConstructible
44///
45/// @{
46template <class F, class T1, class T2 = T1>
47extern constexpr bool is_binary_predicate_v = //
50 F,
53 std::is_move_constructible<remove_cvref_t<F>>::value && //
54 std::is_copy_constructible<remove_cvref_t<F>>::value;
55/// @}
56
57} // namespace base
58} // namespace arene
59#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_IS_BINARY_PREDICATE_HPP_
Definition accumulate.hpp:37
constexpr bool is_predicate_v
backport for the C++20 predicate concept
constexpr bool is_binary_predicate_v
determines if a type satisfies the BinaryPredicate named requirement
Definition accumulate.hpp:36
typename add_lvalue_reference< Type >::type add_lvalue_reference_t
Add an lvalue reference onto Type.
Definition add_lvalue_reference.hpp:63