xtd
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
xtd.core
include
xtd
unsafe.hpp
Go to the documentation of this file.
1
4
#pragma once
5
#include "
is_value_type.hpp
"
6
8
namespace
xtd
{
19
class
unsafe
static_
{
20
public
:
21
template
<
typename
to_type,
typename
from_type>
22
requires
(!
xtd::is_value_type_v<to_type>
)
23
[[nodiscard]]
static
constexpr
auto
as(from_type&& value) -> to_type {
return
static_cast<
to_type
>
(std::forward<from_type>(value));}
24
25
template
<
typename
to_type,
typename
from_type>
26
requires
xtd::is_value_type_v<to_type>
27
[[nodiscard]]
static
constexpr
auto
as(from_type&& value) -> to_type {
28
using
underlying =
typename
to_type::native_type;
29
return
to_type{
static_cast<
underlying
>
(value)};
30
}
31
32
template
<
typename
to_type,
typename
from_type>
33
[[nodiscard]]
static
constexpr
auto
as(
const
from_type* value) -> to_type* {
return
reinterpret_cast<
to_type*
>
(value);}
34
35
template
<
typename
to_type,
typename
from_type>
36
[[nodiscard]]
static
constexpr
auto
as(from_type* value) ->
const
to_type* {
return
reinterpret_cast<
const
to_type*
>
(value);}
37
};
38
}
xtd::unsafe
Contains unsafe cast as operators.
Definition
unsafe.hpp:19
static_
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition
static.hpp:38
xtd::is_value_type_v
constexpr auto is_value_type_v
Convenience variable template equivalent to is_value_type_v<value_t>::value.
Definition
is_value_type.hpp:79
is_value_type.hpp
Contains xtd::is_value_type struct and is_value_type_v struct.
xtd
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition
abstract_object.hpp:8
Generated on
for xtd by
Gammasoft
. All rights reserved.