Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
end.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_END_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_END_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 <iterator>
12// IWYU pragma: friend "stdlib_detail/.*"
13
14#include "stdlib/include/stdlib_detail/cstddef.hpp"
15#include "stdlib/include/stdlib_detail/declval.hpp"
16
17namespace std {
18
19// parasoft-begin-suppress AUTOSAR-M3_3_2-a-2 "False positive: inline function used in multiple translation units"
20// parasoft-begin-suppress AUTOSAR-A5_0_3-a "False positive: there is only 1 level of pointer indirection"
21/// @brief Obtain a pointer to the one-past-the-end element of the array.
22/// @tparam Element The element type of the array
23/// @tparam Size The size of the array
24/// @param array The array
25/// @return A pointer to the one-past-the-end element of @c array
26template <typename Element, size_t Size>
27// NOLINTNEXTLINE(hicpp-avoid-c-arrays)
28constexpr auto end(Element (&array)[Size]) noexcept -> Element* {
29 // parasoft-begin-suppress AUTOSAR-M5_0_15-a "False positive: the pointer points to one-past-the-end of 'array'"
30 return static_cast<Element*>(array) + Size;
31 // parasoft-end-suppress AUTOSAR-M5_0_15-a
32}
33// parasoft-end-suppress AUTOSAR-A5_0_3-a
34// parasoft-end-suppress AUTOSAR-M3_3_2-a-2
35
36// parasoft-begin-suppress AUTOSAR-M3_3_2-a-2 "False positive: inline function used in multiple translation units"
37/// @brief Obtain the result of calling @c cont.end() on a container
38/// @tparam Container The type of the container
39/// @param cont The container object
40/// @return The result of @c cont.end()
41template <typename Container>
42constexpr auto end(Container& cont) noexcept(noexcept(std::declval<Container&>().end())) -> decltype(cont.end()) {
43 return cont.end();
44}
45// parasoft-end-suppress AUTOSAR-M3_3_2-a-2
46
47// parasoft-begin-suppress AUTOSAR-M3_3_2-a-2 "False positive: inline function used in multiple translation units"
48/// @brief Obtain the result of calling @c cont.end() on a @c const container
49/// @tparam Container The type of the container
50/// @param cont The container object
51/// @return The result of @c cont.end()
52template <typename Container>
53constexpr auto end(Container const& cont) noexcept(noexcept(std::declval<Container const&>().end()))
54 -> decltype(cont.end()) {
55 return cont.end();
56}
57// parasoft-end-suppress AUTOSAR-M3_3_2-a-2
58
59// parasoft-begin-suppress AUTOSAR-M3_3_2-a-2 "False positive: inline function used in multiple translation units"
60/// @brief Equivalent to invoking @c end(cont) on a @c const container
61/// @tparam Container The type of the container
62/// @param cont The container object
63/// @return The result of @c cont.end()
64// parasoft-begin-suppress AUTOSAR-A5_0_3 "False positive: No pointer indirection here"
65template <typename Container>
66constexpr auto cend(Container const& cont) noexcept(noexcept(::std::end(std::declval<Container const&>())))
67 -> decltype(::std::end(cont)) {
68 return ::std::end(cont);
69}
70// parasoft-end-suppress AUTOSAR-A5_0_3
71// parasoft-end-suppress AUTOSAR-M3_3_2-a-2
72
73} // namespace std
74
75#endif // INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_END_HPP_
constexpr auto end(Container &cont) noexcept(noexcept(std::declval< Container & >().end())) ->
Obtain the result of calling cont.end() on a container.
Definition end.hpp:42
constexpr auto end(Container const &cont) noexcept(noexcept(std::declval< Container const & >().end())) ->
Obtain the result of calling cont.end() on a const container.
Definition end.hpp:53
constexpr auto end(Element(&array)[Size]) noexcept -> Element *
Obtain a pointer to the one-past-the-end element of the array.
Definition end.hpp:28
constexpr auto cend(Container const &cont) noexcept(noexcept(::std::end(std::declval< Container const & >()))) ->
Equivalent to invoking end(cont) on a const container.
Definition end.hpp:66
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