xtd
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
xtd.core
include
xtd
internal
__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
10
#include "
../convert_pointer.hpp
"
11
13
template
<
typename
new_type,
typename
current_type,
typename
bool
_t>
14
struct
__as_enum__ {};
15
16
template
<
typename
new_type,
typename
current_type>
17
struct
__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
29
template
<
typename
new_type,
typename
current_type>
30
struct
__as_enum__<new_type, current_type, std::false_type> {
31
[[nodiscard]]
auto
convert(
const
current_type& value) ->
const
new_type& {
32
return
xtd::convert_pointer::to_ref<new_type>
(value);
33
}
34
[[nodiscard]]
auto
convert(current_type& value) -> new_type& {
35
return
xtd::convert_pointer::to_ref<new_type>
(value);
36
}
37
};
convert_pointer.hpp
Contains xtd::convert class.
xtd::expressions::operator_precedence::value
@ value
Represnets the constant operator precedence (42).
Definition
operator_precedence.hpp:30
xtd::convert_pointer::to_ref
static auto to_ref(const current_type &value) -> const new_type &
Casts a type into another type.
Definition
convert_pointer.hpp:160
Generated on
for xtd by
Gammasoft
. All rights reserved.