xtd 0.2.0
Loading...
Searching...
No Matches
__as_pointer.h
Go to the documentation of this file.
1
3#pragma once
4
6#if !defined(__XTD_CORE_INTERNAL__)
7#error "Do not include this file: Internal use only"
8#endif
10
12namespace xtd {
29 template<typename new_type_t, typename current_type_t>
30 const new_type_t& as(const current_type_t& value) {
31 thread_local static __as_enum__<new_type_t, current_type_t, typename std::is_enum<current_type_t>::type> e;
32 return e.convert(value);
33 }
34
51 template<typename new_type_t, typename current_type_t>
52 new_type_t& as(current_type_t& value) {
53 thread_local static __as_enum__<new_type_t, current_type_t, typename std::is_enum<current_type_t>::type> e;
54 return e.convert(value);
55 }
56
72 template<typename new_type_t, typename current_type_t>
73 const new_type_t* as(const current_type_t* value) {
74 return xtd::convert_pointer::to_ptr<new_type_t>(value);
75 }
76
92 template<typename new_type_t, typename current_type_t>
93 new_type_t* as(current_type_t* value) {
94 return xtd::convert_pointer::to_ptr<new_type_t>(value);
95 }
96
113 template<typename new_type_t, typename current_type_t>
115 return xtd::convert_pointer::to_unique_ptr<new_type_t>(value);
116 }
117
133 template<typename new_type_t, typename current_type_t>
135 return xtd::convert_pointer::to_unique_ptr<new_type_t>(value);
136 }
137
154 template<typename new_type_t, typename current_type_t>
156 return xtd::convert_pointer::to_shared_ptr<new_type_t>(value);
157 }
158
174 template<typename new_type_t, typename current_type_t>
176 return xtd::convert_pointer::to_shared_ptr<new_type_t>(value);
177 }
178
195 template<typename new_type_t, typename current_type_t>
197 return xtd::convert_pointer::to_shared_ptr<new_type_t>(value);
198 }
199}
std::unique_ptr< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.h:25
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.h:25
type_t as(any_object &o)
Casts a type into another type.
Definition __as_any_object.h:57
@ e
The E key.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10