Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
is_convertible.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_IS_CONVERTIBLE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_IS_CONVERTIBLE_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// parasoft-begin-suppress AUTOSAR-A2_11_1-a-2 "volatile usage required for correct implementation"
12
13// IWYU pragma: private, include <type_traits>
14// IWYU pragma: friend "stdlib_detail/.*"
15
16#include "arene/base/constraints.hpp"
17#include "stdlib/include/stdlib_detail/declval.hpp"
18#include "stdlib/include/stdlib_detail/enable_if.hpp"
19#include "stdlib/include/stdlib_detail/integral_constant.hpp"
20#include "stdlib/include/stdlib_detail/is_same.hpp"
21#include "stdlib/include/stdlib_detail/remove_cv.hpp"
22
23namespace std {
24
26// parasoft-begin-suppress AUTOSAR-A2_7_3-a "False positive: these is a comment with @brief"
27// parasoft-begin-suppress AUTOSAR-M3_3_2-a-2 "This must be the same declaration in all TUs to avoid ODR violations"
28// parasoft-begin-suppress CERT_C-EXP37-a-3 "False positive: The rule does not mention naming all parameters"
29// parasoft-begin-suppress AUTOSAR-A5_0_3-a "False positive: The argument is a template parameter"
30/// @brief Implementation function declared but not defined that accepts an argument of the specified type
31/// @tparam To The type of the argument
32template <typename To>
33void check(To) noexcept;
34// parasoft-end-suppress AUTOSAR-A5_0_3-a
35// parasoft-end-suppress CERT_C-EXP37-a-3
36// parasoft-end-suppress AUTOSAR-M3_3_2-a-2
37// parasoft-end-suppress AUTOSAR-A2_7_3-a
38
39/// @brief Type trait for checking if @c TypeToCheck has the same cv-qualification as @c Baseline, or is more
40/// cv-qualified.
41/// @tparam TypeToCheck The type to check
42/// @tparam Baseline The type to check against
43template <typename TypeToCheck, typename Baseline, typename = arene::base::constraints<>>
44extern constexpr bool is_same_or_more_cv_qualified_v = false;
45
46/// @brief Type trait for checking if @c TypeToCheck has the same cv-qualification as @c Baseline, or is more
47/// cv-qualified.
48///
49/// This specialization is for the case that @c Baseline is not cv-qualified
50/// @tparam TypeToCheck The type to check
51/// @tparam Baseline The type to check against
52template <typename TypeToCheck, typename Baseline>
53extern constexpr bool is_same_or_more_cv_qualified_v<
57
58/// @brief Type trait for checking if @c TypeToCheck has the same cv-qualification as @c Baseline, or is more
59/// cv-qualified.
60///
61/// This specialization is for the case that @c Baseline is @c const and @c TypeToCheck is @c const
62/// @tparam TypeToCheck The type to check
63/// @tparam Baseline The type to check against
64template <typename TypeToCheck, typename Baseline>
65extern constexpr bool is_same_or_more_cv_qualified_v<
66 TypeToCheck const,
67 Baseline const,
71
72/// @brief Type trait for checking if @c TypeToCheck has the same cv-qualification as @c Baseline, or is more
73/// cv-qualified.
74///
75/// This specialization is for the case that @c Baseline is @c const and @c TypeToCheck is @c const @c volatile
76/// @tparam TypeToCheck The type to check
77/// @tparam Baseline The type to check against
78template <typename TypeToCheck, typename Baseline>
79extern constexpr bool is_same_or_more_cv_qualified_v<
80 TypeToCheck const volatile,
81 Baseline const,
85
86/// @brief Type trait for checking if @c TypeToCheck has the same cv-qualification as @c Baseline, or is more
87/// cv-qualified.
88///
89/// This specialization is for the case that @c Baseline is @c volatile and @c TypeToCheck is @c volatile
90/// @tparam TypeToCheck The type to check
91/// @tparam Baseline The type to check against
92template <typename TypeToCheck, typename Baseline>
93extern constexpr bool is_same_or_more_cv_qualified_v<
94 TypeToCheck volatile,
95 Baseline volatile,
99
100/// @brief Type trait for checking if @c TypeToCheck has the same cv-qualification as @c Baseline, or is more
101/// cv-qualified.
102///
103/// This specialization is for the case that @c Baseline is @c volatile and @c TypeToCheck is @c const @c volatile
104/// @tparam TypeToCheck The type to check
105/// @tparam Baseline The type to check against
106template <typename TypeToCheck, typename Baseline>
107extern constexpr bool is_same_or_more_cv_qualified_v<
108 TypeToCheck const volatile,
109 Baseline volatile,
113
114/// @brief Type trait for checking if @c TypeToCheck has the same cv-qualification as @c Baseline, or is more
115/// cv-qualified.
116///
117/// This specialization is for the case that @c Baseline is @c const @c volatile and @c TypeToCheck is @c const @c
118/// volatile
119/// @tparam TypeToCheck The type to check
120/// @tparam Baseline The type to check against
121template <typename TypeToCheck, typename Baseline>
122extern constexpr bool is_same_or_more_cv_qualified_v<
123 TypeToCheck const volatile,
124 Baseline const volatile,
128
129/// @brief Type trait to detect if one type is convertible to another
130/// @tparam From The type to (try to) convert from
131/// @tparam To The type to (try to) convert to
132template <typename From, typename To, typename = arene::base::constraints<>>
133extern constexpr bool is_convertible_v = false;
134
135/// @brief Type trait to detect if one type is convertible to another.
136///
137/// This specialization handles the case that they are
138/// @tparam From The type to (try to) convert from
139/// @tparam To The type to (try to) convert to
140template <typename From, typename To>
141extern constexpr bool
143 true;
144
145/// @brief Type trait to detect if one type is convertible to another.
146///
147/// This specialization handles the case that the source and target are both @c void
148/// @tparam From The type to (try to) convert from
149/// @tparam To The type to (try to) convert to
150template <typename From, typename To>
151extern constexpr bool is_convertible_v<
152 From,
153 To,
158
159} // namespace is_convertible_detail
160
161/// @brief Type trait to detect if one type is convertible to another
162/// @tparam From The type to (try to) convert from
163/// @tparam To The type to (try to) convert to
164template <typename From, typename To>
166
167/// @brief Type trait to detect if one type is convertible to another
168/// @tparam From The type to (try to) convert from
169/// @tparam To The type to (try to) convert to
170template <typename From, typename To>
172
173} // namespace std
174
175#endif // INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_IS_CONVERTIBLE_HPP_
Type trait to detect if one type is convertible to another.
Definition is_convertible.hpp:171
Definition is_convertible.hpp:25
void check(To) noexcept
Implementation function declared but not defined that accepts an argument of the specified type.
constexpr bool is_same_or_more_cv_qualified_v
Type trait for checking if TypeToCheck has the same cv-qualification as Baseline, or is more cv-quali...
constexpr bool is_convertible_v
Type trait to detect if one type is convertible to another.
constexpr bool is_convertible_v
Type trait to detect if one type is convertible to another.
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