12template<
class new_type,
class current_type>
13new_type* __convert_value__(current_type* value);
44 template<
class new_type,
class current_type>
45 static const new_type*
to_ptr(
const current_type* value) {
46 if (value ==
nullptr)
return nullptr;
61 template<
class new_type,
class current_type>
62 static new_type*
to_ptr(current_type* value) {
63 if (value ==
nullptr)
return nullptr;
78 template<
class new_type,
class current_type>
79 static const new_type*
to_ptr(
const current_type& value) {
94 template<
class new_type,
class current_type>
95 static new_type*
to_ptr(current_type& value) {
111 template<
class new_type,
class current_type>
127 template<
class new_type,
class current_type>
144 template<
class new_type,
class current_type>
161 template<
class new_type,
class current_type>
162 static const new_type&
to_ref(
const current_type& value) {
164 return dynamic_cast<const new_type&
>(value);
165 }
catch (
const std::exception&
e) {
183 template<
class new_type,
class current_type>
184 static new_type&
to_ref(current_type& value) {
186 return dynamic_cast<new_type&
>(value);
187 }
catch (
const std::exception&
e) {
205 template<
class new_type,
class current_type>
206 static const new_type&
to_ref(
const current_type* value) {
209 return dynamic_cast<const new_type&
>(*value);
210 }
catch (
const std::exception&
e) {
228 template<
class new_type,
class current_type>
229 static new_type&
to_ref(current_type* value) {
232 return dynamic_cast<new_type&
>(*value);
233 }
catch (
const std::exception&
e) {
251 template<
class new_type,
class current_type>
254 [[maybe_unused]]
auto result =
dynamic_cast<new_type&
>(*value.get());
255 }
catch (
const std::exception&
e) {
258 return std::dynamic_pointer_cast<new_type>(value.pointer());
272 template<
class new_type,
class current_type>
275 [[maybe_unused]]
auto& result =
dynamic_cast<new_type&
>(*value.get());
276 }
catch (
const std::exception&
e) {
279 return std::dynamic_pointer_cast<new_type>(value.pointer());
294 template<
class new_type,
class current_type>
297 [[maybe_unused]]
auto& result =
dynamic_cast<new_type&
>(*value.get());
298 }
catch (
const std::exception&
e) {
302 return std::dynamic_pointer_cast<new_type>(std::move(value.pointer()));
317 template<
class new_type,
class current_type>
333 template<
class new_type,
class current_type>
350 template<
class new_type,
class current_type>
367 template<
class new_type,
class current_type>
369 auto ptr = value.release();
372 }
catch (
const std::exception&
e) {
390 template<
class new_type,
class current_type>
392 auto ptr = value.release();
395 }
catch (
const std::exception&
e) {
414 template<
class new_type,
class current_type>
430 template<
class new_type,
class current_type>
Contains xtd::any type and std::bad_any_cast exception.
Contains xtd::argument_null_exception exception.
Represents API to convert pointers.
Definition convert_pointer.hpp:29
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
@ invalid_cast
The cast is not valid.
Definition exception_case.hpp:63
@ argument_null
The argument is null.
Definition exception_case.hpp:33
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.hpp:37
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
xtd::unique_ptr_object< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
static xtd::ptr< new_type > to_ptr(xtd::ptr< current_type > &value)
Casts a type into another type.
Definition convert_pointer.hpp:128
static xtd::uptr< new_type > to_unique_ptr(xtd::uptr< current_type > &value)
Casts a type into another type.
Definition convert_pointer.hpp:368
static xtd::uptr< new_type > to_unique_ptr(xtd::uptr< current_type > &&value)
Casts a type into another type.
Definition convert_pointer.hpp:391
static xtd::sptr< new_type > to_sptr(xtd::sptr< current_type > &&value)
Casts a type into another type.
Definition convert_pointer.hpp:351
static new_type & to_ref(current_type *value)
Casts a type into another type.
Definition convert_pointer.hpp:229
static const new_type * to_ptr(const current_type &value)
Casts a type into another type.
Definition convert_pointer.hpp:79
static const new_type * to_ptr(const current_type *value)
Casts a type into another type.
Definition convert_pointer.hpp:45
static const new_type & to_ref(const current_type &value)
Casts a type into another type.
Definition convert_pointer.hpp:162
static xtd::sptr< new_type > to_sptr(xtd::sptr< current_type > &value)
Casts a type into another type.
Definition convert_pointer.hpp:334
static xtd::sptr< new_type > to_sptr(const xtd::sptr< current_type > &value)
Casts a type into another type.
Definition convert_pointer.hpp:318
static new_type * to_ptr(current_type *value)
Casts a type into another type.
Definition convert_pointer.hpp:62
static xtd::uptr< new_type > to_uptr(xtd::uptr< current_type > &value)
Casts a type into another type.
Definition convert_pointer.hpp:415
static xtd::ptr< new_type > to_ptr(xtd::ptr< current_type > &&value)
Casts a type into another type.
Definition convert_pointer.hpp:145
static new_type * to_ptr(current_type &value)
Casts a type into another type.
Definition convert_pointer.hpp:95
static const new_type & to_ref(const current_type *value)
Casts a type into another type.
Definition convert_pointer.hpp:206
static new_type & to_ref(current_type &value)
Casts a type into another type.
Definition convert_pointer.hpp:184
static xtd::sptr< new_type > to_shared_ptr(xtd::sptr< current_type > &value)
Casts a type into another type.
Definition convert_pointer.hpp:273
static xtd::uptr< new_type > to_uptr(xtd::uptr< current_type > &&value)
Casts a type into another type.
Definition convert_pointer.hpp:431
static xtd::ptr< new_type > to_ptr(const xtd::ptr< current_type > &value)
Casts a type into another type.
Definition convert_pointer.hpp:112
static xtd::sptr< new_type > to_shared_ptr(xtd::sptr< current_type > &&value)
Casts a type into another type.
Definition convert_pointer.hpp:295
static xtd::sptr< new_type > to_shared_ptr(const xtd::sptr< current_type > &value)
Casts a type into another type.
Definition convert_pointer.hpp:252
@ e
The E key.
Definition console_key.hpp:96
Contains xtd::invalid_cast_exception exception.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::static_object class.
Contains xtd fundamental types.