Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
max_initializer_list_overload.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_MAX_INITIALIZER_LIST_OVERLOAD_HPP_
6
#
define
INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_MAX_INITIALIZER_LIST_OVERLOAD_HPP_
7
8
// parasoft-begin-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
9
#
include
"arene/base/algorithm/detail/functional.hpp"
10
#
include
"arene/base/algorithm/detail/traits.hpp"
11
#
include
"arene/base/constraints.hpp"
12
#
include
"arene/base/contracts.hpp"
13
#
include
"arene/base/type_traits/is_compare.hpp"
14
#
include
"stdlib/include/stdlib_detail/declval.hpp"
15
#
include
"stdlib/include/stdlib_detail/enable_if.hpp"
16
#
include
"stdlib/include/stdlib_detail/initializer_list.hpp"
17
#
include
"stdlib/include/stdlib_detail/internal_relative_find.hpp"
18
#
include
"stdlib/include/stdlib_detail/is_copy_constructible.hpp"
19
// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
20
21
// parasoft-begin-suppress CERT_CPP-DCL58-a-2 "Part of a standard library implementation"
22
// parasoft-begin-suppress AUTOSAR-A17_6_1-a-2 "Part of a standard library implementation"
23
24
// IWYU pragma: private, include <algorithm>
25
// IWYU pragma: friend "stdlib_detail/.*"
26
27
namespace
std
{
28
29
// parasoft-begin-suppress AUTOSAR-M3_3_2-a-2 "False positive: inline function used in multiple translation units"
30
// parasoft-begin-suppress AUTOSAR-M17_0_3-a "This is an implementation of the standard library function"
31
32
/// @brief Returns the largest value in the @c std::initializer_list
33
/// @tparam T The type of the values in the @c std::initializer_list
34
/// @tparam Compare The type of the comparison function
35
/// @param list The list of values to compare
36
/// @param comp The comparison function which returns true if the first parameter is less than the second
37
/// @return Returns the largest value in @c list using the comparison function @c comp to compare the values
38
///
39
/// @pre <tt> list.size() > 0 </tt>
40
/// @pre <tt> std::is_copy_constructible<T>::value == true </tt>
41
/// @pre The expression <tt>comp(a, b)</tt> must be convertible to @c bool
42
/// for every argument @c a, @c b of type <tt> T const& </tt>.
43
template
<
44
class
T
,
45
class
Compare
,
46
arene
::
base
::
constraints
<
47
std
::
enable_if_t
<
std
::
is_copy_constructible_v
<
T
>>,
48
std
::
enable_if_t
<
arene
::
base
::
is_compare_v
<
Compare
&,
T
const
&>>> =
nullptr
>
49
constexpr
auto
max
(
50
initializer_list
<
T
>
list
,
51
Compare
comp
52
)
noexcept
(
noexcept
(
comp
(
std
::
declval
<
T
&>(),
std
::
declval
<
T
&>())) &&
std
::
is_nothrow_copy_constructible_v
<
T
>) ->
T
{
53
ARENE_PRECONDITION
(
list
.
size
() >
std
::
size_t
{0});
54
return
*
std
::
internal
::
relative_find
(
list
.
begin
(),
list
.
end
(),
arene
::
base
::
algorithm_detail
::
flip
(
comp
));
55
}
56
57
/// @brief Returns the largest value in the @c std::initializer_list
58
/// @tparam T The type of the values in the @c std::initializer_list
59
/// @param list The list of values to compare
60
/// @return Returns the largest value in @c list
61
///
62
/// @pre <tt> list.size() > 0 </tt>
63
/// @pre <tt> std::is_copy_constructible<T>::value == true </tt>
64
/// @pre The expression <tt>comp(a, b)</tt> must be convertible to @c bool
65
/// for every argument @c a, @c b of type <tt> T const& </tt>.
66
template
<
67
class
T
,
68
arene
::
base
::
constraints
<
69
std
::
enable_if_t
<
std
::
is_copy_constructible_v
<
T
>>,
70
std
::
enable_if_t
<
71
arene
::
base
::
is_compare_v
<
decltype
(
arene
::
base
::
algorithm_detail
::
operator_less
)&,
T
const
&>>> =
nullptr
>
72
constexpr
auto
max
(
initializer_list
<
T
>
list
73
)
noexcept
(
noexcept
(
std
::
max
(
list
,
arene
::
base
::
algorithm_detail
::
operator_less
))) ->
T
{
74
return
max
(
list
,
arene
::
base
::
algorithm_detail
::
operator_less
);
75
}
76
77
// parasoft-end-suppress AUTOSAR-M3_3_2-a-2
78
// parasoft-end-suppress AUTOSAR-M17_0_3-a
79
80
}
// namespace std
81
82
#
endif
// INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_MAX_INITIALIZER_LIST_OVERLOAD_HPP_
std::hash<::arene::base::result< void, E > >::operator()
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
stdlib
include
stdlib_detail
max_initializer_list_overload.hpp
Generated by
1.13.2