Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
upper_bound.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_UPPER_BOUND_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_UPPER_BOUND_HPP_
7
8#include "arene/base/algorithm/detail/functional.hpp"
9#include "arene/base/algorithm/detail/traits.hpp"
10#include "arene/base/constraints.hpp"
11#include "arene/base/functional/bind_front.hpp"
12#include "arene/base/functional/not_fn.hpp"
13#include "arene/base/type_traits/is_binary_predicate.hpp"
14#include "arene/base/type_traits/iterator_category_traits.hpp"
15#include "stdlib/include/stdlib_detail/declval.hpp"
16#include "stdlib/include/stdlib_detail/enable_if.hpp"
17#include "stdlib/include/stdlib_detail/internal_partition_point.hpp"
18#include "stdlib/include/stdlib_detail/move.hpp"
19
20// parasoft-begin-suppress CERT_CPP-DCL58-a-2 "Part of a standard library implementation"
21// parasoft-begin-suppress AUTOSAR-A17_6_1-a-2 "Part of a standard library implementation"
22
23// IWYU pragma: private, include <algorithm>
24// IWYU pragma: friend "stdlib_detail/.*"
25
26namespace std {
27
28// parasoft-begin-suppress AUTOSAR-M3_3_2-a "False positive: inline function used in multiple translation units"
29
30/// @brief returns an iterator to the first element greater than the given value
31/// @tparam ForwardIterator iterator type
32/// @tparam T value type to compare against
33/// @tparam Compare binary predicate type
34/// @param first beginning of the partitioned range of elements
35/// @param last end of the partitioned range of elements
36/// @param value value to compare elements to
37/// @param comp binary predicate which returns @c true if the first argument is ordered before the second
38///
39/// @pre @c ForwardIterator must satisfy the forward iterator requirements.
40/// @pre <tt>[begin, end)</tt> must be a valid range.
41/// @pre The expression <tt>comp(value, e)</tt> must be convertible to @c bool
42/// for every argument @c e of type @c RT, where @c RT is the reference type
43/// of @c ForwardIterator, regardless of value category, and must not modify
44/// @c e or @c value.
45/// @pre The elements @c e of <tt>[begin, end)</tt> must be partitioned with
46/// respect to the expression <tt>comp(value, e)</tt>.
47///
48/// @return iterator to the first element of the range <tt>[first, last)</tt>
49/// ordered after @c value, or @c last if no such element is found.
50///
51/// @note Complexity
52/// Given N as <tt>std::distance(first, last)</tt>, at most <tt>log2(N) +
53/// O(1)</tt> applications of the comparator @c comp.
54///
55template <
56 class ForwardIterator,
57 class T,
58 class Compare,
62 Compare&,
63 T const&,
75
76/// @brief returns an iterator to the first element greater than the given value
77/// @tparam ForwardIterator iterator type
78/// @tparam T value type to compare against
79/// @tparam Compare binary predicate type
80/// @param first beginning of the partitioned range of elements
81/// @param last end of the partitioned range of elements
82/// @param value value to compare elements to
83///
84/// @pre @c ForwardIterator must satisfy the forward iterator requirements.
85/// @pre <tt>[begin, end)</tt> must be a valid range.
86/// @pre The expression <tt>value < e</tt> must be convertible to @c bool
87/// for every argument @c e of type @c RT, where @c RT is the reference type
88/// of @c ForwardIterator, regardless of value category, and must not modify
89/// @c e or @c value.
90/// @pre The elements @c e of <tt>[begin, end)</tt> must be partitioned with
91/// respect to the expression <tt>value < e</tt>.
92///
93/// @return iterator to the first element of the range <tt>[first, last)</tt>
94/// ordered after @c value, or @c last if no such element is found.
95///
96/// @note Complexity
97/// Given N as <tt>std::distance(first, last)</tt>, at most <tt>log2(N) +
98/// O(1)</tt> comparisons with @c value using @c operator<.
99///
100template <
101 class ForwardIterator,
102 class T,
107 T const&,
114
115// parasoft-end-suppress AUTOSAR-M3_3_2-a
116
117} // namespace std
118
119#endif // INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_UPPER_BOUND_HPP_
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