Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
addressof.hpp
Go to the documentation of this file.
1// Copyright 2024, 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_ADDRESSOF_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_ADDRESSOF_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 <memory>
12// IWYU pragma: friend "stdlib_detail/.*"
13
14namespace std {
15
16// parasoft-begin-suppress AUTOSAR-M3_3_2-a-2 "False positive: inline function used in multiple translation units"
17// parasoft-begin-suppress AUTOSAR-A0_1_4-a-2 "False positive: parameter is used"
18// parasoft-begin-suppress AUTOSAR-A5_0_3-a "False positive: there is only 1 level of pointer indirection"
19/// @brief Obtains the actual address of the object or function arg, even in presence of overloaded operator&.
20/// @tparam T The type of the value
21/// @param value The value to take the address of
22/// @return The address of the supplied value
23template <class T>
24constexpr auto addressof(T& value) noexcept -> T* {
25 return __builtin_addressof(value);
26}
27// parasoft-end-suppress AUTOSAR-A5_0_3-a
28// parasoft-end-suppress AUTOSAR-A0_1_4-a-2
29// parasoft-begin-suppress AUTOSAR-M3_3_2-a-2
30
31// parasoft-begin-suppress CERT_C-EXP37-a-3 "False positive: Unused parameter does not need to be named"
32// parasoft-begin-suppress AUTOSAR-A5_0_3-a "False positive: there is only 1 level of pointer indirection"
33/// @brief Obtains the actual address of the object or function arg, even in presence of overloaded operator&.
34/// @tparam T The type of the value
35/// @return The address of the supplied value
36template <class T>
37constexpr auto addressof(T const&&) noexcept -> T const* = delete;
38// parasoft-end-suppress CERT_C-EXP37-a-3
39// parasoft-end-suppress AUTOSAR-A5_0_3-a
40
41} // namespace std
42
43#endif // INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_ADDRESSOF_HPP_
constexpr auto addressof(T const &&) noexcept -> T const *=delete
Obtains the actual address of the object or function arg, even in presence of overloaded operator&.
constexpr auto addressof(T &value) noexcept -> T *
Obtains the actual address of the object or function arg, even in presence of overloaded operator&.
Definition addressof.hpp:24
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