Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
has_overloaded_address_operator.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_ARENE_BASE_TYPE_TRAITS_HAS_OVERLOADED_ADDRESS_OPERATOR_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_HAS_OVERLOADED_ADDRESS_OPERATOR_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/constraints/substitution_succeeds.hpp"
12#include "arene/base/stdlib_choice/declval.hpp"
13#include "arene/base/stdlib_choice/enable_if.hpp"
14#include "arene/base/stdlib_choice/integral_constant.hpp"
15#include "arene/base/stdlib_choice/is_class.hpp"
16#include "arene/base/stdlib_choice/is_same.hpp"
17
18namespace arene {
19namespace base {
20
21namespace has_overloaded_address_operator_detail {
22/// @brief Check if a type has the expected return types for the address operator; instantiation fails if @c T does not
23/// match the expected signature for @c operator&
24/// @tparam T The type to check
25// parasoft-begin-suppress AUTOSAR-A2_7_3 "False positive: documented"
26template <
27 typename T,
28 typename = std::enable_if_t<
29 std::is_same<decltype(&std::declval<T&>()), T*>::value &&
30 std::is_same<decltype(&std::declval<T const&>()), T const*>::value>>
31struct has_normal_address_operator_types {};
32// parasoft-end-suppress AUTOSAR-A2_7_3
33
34/// @brief Check if a type has an address operator for non-const values; instantiation fails if @c T does not have an
35/// address operator overload that works for non-const objects
36/// @tparam T The type to check
37// parasoft-begin-suppress AUTOSAR-A2_7_3 "False positive: documented"
38template <typename T, typename = decltype(static_cast<T* (T::*)()>(&T::operator&))>
39struct has_overloaded_address_operator_for_lvalue {};
40// parasoft-end-suppress AUTOSAR-A2_7_3
41
42/// @brief Check if a type has an address operator for const values; instantiation fails if @c T does not have an
43/// address operator overload that works for const objects
44/// @tparam T The type to check
45// parasoft-begin-suppress AUTOSAR-A2_7_3 "False positive: documented"
46template <typename T, typename = decltype(static_cast<T const* (T::*)() const>(&T::operator&))>
47struct has_overloaded_address_operator_for_const_lvalue {};
48// parasoft-end-suppress AUTOSAR-A2_7_3
49
50} // namespace has_overloaded_address_operator_detail
51
52/// @brief Type trait to check if a type has an overloaded address operator; the value is @c true if the type has an
53/// overloaded address operator, @c false otherwise
54/// @tparam T The type to check
55template <typename T>
56extern constexpr bool has_overloaded_address_operator_v =
57 std::is_class<T>::value &&
62 T>);
63
64/// @brief Type trait to check if a type has an overloaded address operator; the class derives from @c true_type if the
65/// type has an overloaded address operator, @c false_type otherwise
66/// @tparam T The type to check
67// parasoft-begin-suppress AUTOSAR-A2_7_3 "False positive: documented"
68template <typename T>
70// parasoft-end-suppress AUTOSAR-A2_7_3
71
72} // namespace base
73} // namespace arene
74
75#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_HAS_OVERLOADED_ADDRESS_OPERATOR_HPP_
Type trait to check if a type has an overloaded address operator; the class derives from true_type if...
Definition has_overloaded_address_operator.hpp:69
Definition array_exceptions_disabled.cpp:11
constexpr bool has_overloaded_address_operator_v
Type trait to check if a type has an overloaded address operator; the value is true if the type has a...
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10