tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
to_underlying.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_UTILITY_TO_UNDERLYING_HPP
5#define TETL_UTILITY_TO_UNDERLYING_HPP
6
7#include <etl/_type_traits/underlying_type.hpp>
8
9namespace etl {
10
11/// \brief Converts an enumeration to its underlying type.
12///
13/// https://en.cppreference.com/w/cpp/utility/to_underlying
14template <typename Enum>
15[[nodiscard]] constexpr auto to_underlying(Enum e) noexcept -> underlying_type_t<Enum>
16{
17 return static_cast<underlying_type_t<Enum>>(e);
18}
19
20} // namespace etl
21
22#endif // TETL_UTILITY_TO_UNDERLYING_HPP
Definition adjacent_find.hpp:9
constexpr auto to_underlying(Enum e) noexcept -> underlying_type_t< Enum >
Converts an enumeration to its underlying type.
Definition to_underlying.hpp:15