tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
underlying_type.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_TYPE_TRAITS_IS_UNDERLYING_TYPE_HPP
5#define TETL_TYPE_TRAITS_IS_UNDERLYING_TYPE_HPP
6
7#include <etl/_config/all.hpp>
8
9#include <etl/_type_traits/is_enum.hpp>
10
11namespace etl {
12
13namespace detail {
14template <typename T>
15struct underlying_type { };
16
17template <typename T>
18 requires is_enum_v<T>
19struct underlying_type<T> {
20 using type = __underlying_type(T);
21};
22
23} // namespace detail
24
25/// The underlying type of an enum.
26/// \ingroup type_traits
27template <typename T>
28struct underlying_type : detail::underlying_type<T> { };
29
30/// \ingroup type_traits
31template <typename T>
32using underlying_type_t = typename underlying_type<T>::type;
33
34} // namespace etl
35
36#endif // TETL_TYPE_TRAITS_IS_UNDERLYING_TYPE_HPP
Definition adjacent_find.hpp:9
The underlying type of an enum.
Definition underlying_type.hpp:28