Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
underlying_type.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_UNDERLYING_TYPE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_UNDERLYING_TYPE_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#include "arene/base/constraints.hpp"
12#include "stdlib/include/stdlib_detail/enable_if.hpp"
13#include "stdlib/include/stdlib_detail/is_enum.hpp"
14
15// IWYU pragma: private, include <type_traits>
16// IWYU pragma: friend "stdlib_detail/.*"
17
18namespace std {
20
21// parasoft-begin-suppress AUTOSAR-A2_7_3-a "False positive: all declarations
22// and typedefs *are* preceded by a comment with @brief"
23
24/// @brief Helper trait used to implement @c std::underlying_type
25/// @tparam T The type to get the underlying type of
26///
27/// The primary template does not define member @c type.
28///
29template <typename T, typename = arene::base::constraints<>>
31
32/// @brief Helper trait specialization used to implement @c std::underlying_type
33/// if @c T is an enumeration type
34/// @tparam T The type to get the underlying type of
35///
36template <typename T>
38 /// @brief The underlying integer type
39 using type = __underlying_type(T);
40};
41
42} // namespace underlying_type_detail
43
44/// @brief Obtains the underlying integer type for a given enumeration type
45/// @tparam T Enumeration type
46///
47/// Provides member type alias @c type that names the underlying type of @c T if
48/// @c T is an enumeration type. If @c T is not an enumeration type, there is no
49/// member @c type.
50///
51template <typename T>
53
54/// @brief An alias for the underlying type of @c T, if @c T is an enumeration type
55/// @tparam T The type to get the underlying type of
56///
57template <typename T>
59
60// parasoft-end-suppress AUTOSAR-A2_7_3-a
61
62} // namespace std
63
64#endif // INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_UNDERLYING_TYPE_HPP_
Definition underlying_type.hpp:19
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
Helper trait used to implement std::underlying_type.
Definition underlying_type.hpp:30