sandbox
Loading...
Searching...
No Matches
cast.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_UTILITY_CAST_HPP_
3#define LIBSBX_UTILITY_CAST_HPP_
4
5#include <type_traits>
6
7namespace sbx::utility {
8
9template<typename Type>
10[[nodiscard]] constexpr auto underlying_cast(Type value) noexcept -> std::underlying_type_t<Type> {
11 return static_cast<std::underlying_type_t<Type>>(value);
12}
13
14template<typename Type>
15[[nodiscard]] constexpr auto implicit_cast(std::type_identity_t<Type> value) noexcept(std::is_nothrow_move_constructible_v<Type>) -> Type {
16 return value;
17}
18
19} // namespace sbx::utility
20
21#endif // LIBSBX_UTILITY_CAST_HPP_