xtd 0.2.0
Loading...
Searching...
No Matches
unsafe.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "is_value_type.hpp"
6
8namespace xtd {
20 public:
21 template<class to_type, class from_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<class to_type, class from_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<class to_type, class from_type>
33 [[nodiscard]] static constexpr auto as(const from_type* value) -> to_type* {return reinterpret_cast<to_type*>(value);}
34
35 template<class to_type, class from_type>
36 [[nodiscard]] static constexpr auto as(from_type* value) -> const to_type* {return reinterpret_cast<const to_type*>(value);}
37 };
38}
Contains unsafe cast as operators.
Definition unsafe.hpp:19
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.hpp:38
constexpr bool is_value_type_v
Convenience variable template equivalent to is_stream_insertable_v<value_t>::value.
Definition is_value_type.hpp:79
Contains xtd::is_stream_insertable struct and is_stream_insertable_v struct.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8