xtd 0.2.0
Loading...
Searching...
No Matches
__as_enum.hpp
Go to the documentation of this file.
1
3#pragma once
5#if !defined(__XTD_CORE_INTERNAL__)
6#error "Do not include this file: Internal use only"
7#endif
9
11
13template<class new_type, class current_type, class bool_t>
14struct __as_enum__ {};
15
16template<class new_type, class current_type>
17struct __as_enum__<new_type, current_type, std::true_type> {
18 [[nodiscard]] auto convert(const current_type& value) -> const new_type& {
19 __result__ = static_cast<new_type>(value);
20 return __result__;
21 }
22 [[nodiscard]] auto convert(current_type& value) -> new_type& {
23 __result__ = static_cast<new_type>(value);
24 return __result__;
25 }
26 thread_local inline static new_type __result__ {};
27};
28
29template<class new_type, class current_type>
30struct __as_enum__<new_type, current_type, std::false_type> {
31 [[nodiscard]] auto convert(const current_type& value) -> const new_type& {
33 }
34 [[nodiscard]] auto convert(current_type& value) -> new_type& {
36 }
37};
Contains xtd::convert class.
static const new_type & to_ref(const current_type &value)
Casts a type into another type.
Definition convert_pointer.hpp:162