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