Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
give_qualifiers_to.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_MANIPULATION_GIVE_QUALIFIERS_TO_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_MANIPULATION_GIVE_QUALIFIERS_TO_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/type_manipulation/static_if.hpp"
10
11namespace arene {
12namespace base {
13
14namespace give_qualifiers_to_detail {
15template <class T>
16constexpr bool is_const_v = false;
17
18template <class T>
19constexpr bool is_const_v<T const> = true;
20
21template <class T>
22constexpr bool is_volatile_v = false;
23
24// parasoft-begin-suppress AUTOSAR-A2_11_1-a-2 "volatile keyword used to check for volatile objects"
25template <class T>
26constexpr bool is_volatile_v<T volatile> = true;
27// parasoft-end-suppress AUTOSAR-A2_11_1-a-2
28
29// parasoft-begin-suppress AUTOSAR-A2_11_1-a-2 "volatile keyword used to preserve qualification of volatile objects"
30/// @brief Implementation detail for implementing "GiveQualifiersTo" below.
31/// @tparam Source The type providing the qualifiers
32/// @tparam Target The type to modify the qualifiers of
33///
34/// This alias handles the case where Source is volatile
35// parasoft-begin-suppress AUTOSAR-A2_7_3 "False positive: documented"
36template <class Source, class Target>
37using give_qualifiers_to_impl_volatile =
38 typename static_if<is_const_v<Source>>::template then_else<Target const volatile, Target volatile>;
39// parasoft-end-suppress AUTOSAR-A2_7_3
40// parasoft-end-suppress AUTOSAR-A2_11_1-a-2
41
42/// @brief Implementation detail for implementing "GiveQualifiersTo" below.
43/// @tparam Source The type providing the qualifiers
44/// @tparam Target The type to modify the qualifiers of
45///
46/// This alias handles the case where Source is not volatile
47// parasoft-begin-suppress AUTOSAR-A2_7_3 "False positive: documented"
48template <class Source, class Target>
49using give_qualifiers_to_impl_nonvolatile =
50 typename static_if<is_const_v<Source>>::template then_else<Target const, Target>;
51// parasoft-end-suppress AUTOSAR-A2_7_3
52
53} // namespace give_qualifiers_to_detail
54
55/// @brief For a type Source and type Target:
56/// if Source is const volatile
57/// results in Target const volatile
58/// otherwise if Source is volatile
59/// results in Target volatile
60/// otherwise if Source is const
61/// result in Target const
62/// otherwise
63/// results in Target
64/// @tparam Source The type providing the qualifiers
65/// @tparam Target The type to modify the qualifiers of
66// parasoft-begin-suppress AUTOSAR-A2_7_3 "False positive: documented"
67template <class Source, class Target>
72 Source,
73 Target>;
74// parasoft-end-suppress AUTOSAR-A2_7_3
75
76} // namespace base
77} // namespace arene
78
79#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_MANIPULATION_GIVE_QUALIFIERS_TO_HPP_
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10