13 template<
typename new_type_t,
typename current_type_t>
14 new_type_t* __convert_value__(current_type_t* value);
44 template<
typename type_t>
45 static const type_t*
to_ptr(
const type_t& value) {
60 template<
typename type_t>
61 static type_t*
to_ptr(type_t& value) {
76 template<
typename type_t>
77 static const type_t*
to_ptr(
const type_t* value) {
92 template<
typename type_t>
93 static type_t*
to_ptr(type_t* value) {
108 template<
typename new_type_t,
typename current_type_t>
109 static const new_type_t*
to_ptr(
const current_type_t* value) {
110 if (value ==
nullptr)
return nullptr;
111 return &to_ref<new_type_t>(*value);
125 template<
typename new_type_t,
typename current_type_t>
126 static new_type_t*
to_ptr(current_type_t* value) {
127 if (value ==
nullptr)
return nullptr;
128 return &to_ref<new_type_t>(*value);
142 template<
typename new_type_t,
typename current_type_t>
143 static const new_type_t*
to_ptr(
const current_type_t& value) {
144 return &to_ref<new_type_t>(value);
158 template<
typename new_type_t,
typename current_type_t>
159 static new_type_t*
to_ptr(current_type_t& value) {
160 return &to_ref<new_type_t>(value);
175 template<
typename type_t>
176 static const type_t&
to_ref(
const type_t& value) {
192 template<
typename type_t>
208 template<
typename type_t>
209 static const type_t&
to_ref(
const type_t* value) {
225 template<
typename type_t>
243 template<
typename new_type_t,
typename current_type_t>
244 static const new_type_t&
to_ref(
const current_type_t& value) {
246 return dynamic_cast<const new_type_t&
>(value);
247 }
catch (
const std::exception&
e) {
265 template<
typename new_type_t,
typename current_type_t>
266 static new_type_t&
to_ref(current_type_t& value) {
268 return dynamic_cast<new_type_t&
>(value);
269 }
catch (
const std::exception&
e) {
287 template<
typename new_type_t,
typename current_type_t>
288 static const new_type_t&
to_ref(
const current_type_t* value) {
291 return dynamic_cast<const new_type_t&
>(*value);
292 }
catch (
const std::exception&
e) {
310 template<
typename new_type_t,
typename current_type_t>
311 static new_type_t&
to_ref(current_type_t* value) {
314 return dynamic_cast<new_type_t&
>(*value);
315 }
catch (
const std::exception&
e) {
333 template<
typename new_type_t,
typename current_type_t>
334 static std::unique_ptr<new_type_t>
to_unique_ptr(std::unique_ptr<current_type_t>& value) {
336 return std::unique_ptr<new_type_t>(__convert_value__<new_type_t>(value.release()));
337 }
catch (
const std::exception&
e) {
354 template<
typename new_type_t,
typename current_type_t>
355 static std::unique_ptr<new_type_t>
to_unique_ptr(std::unique_ptr<current_type_t>&& value) {
357 return std::unique_ptr<new_type_t>(__convert_value__<new_type_t>(value.release()));
358 }
catch (
const std::exception&
e) {
376 template<
typename new_type_t,
typename current_type_t>
377 static std::shared_ptr<new_type_t>
to_shared_ptr(
const std::shared_ptr<current_type_t>& value) {
379 unused_(dynamic_cast<new_type_t&>(*value.get()));
380 }
catch (
const std::exception&
e) {
383 return std::dynamic_pointer_cast<new_type_t>(value);
397 template<
typename new_type_t,
typename current_type_t>
398 static std::shared_ptr<new_type_t>
to_shared_ptr(std::shared_ptr<current_type_t>& value) {
400 unused_(dynamic_cast<new_type_t&>(*value.get()));
401 }
catch (
const std::exception&
e) {
404 return std::dynamic_pointer_cast<new_type_t>(value);
419 template<
typename new_type_t,
typename current_type_t>
420 static std::shared_ptr<new_type_t>
to_shared_ptr(std::shared_ptr<current_type_t>&& value) {
422 unused_(dynamic_cast<new_type_t&>(*value.get()));
423 }
catch (
const std::exception&
e) {
427 return std::dynamic_pointer_cast<new_type_t>(std::move(value));
The exception that is thrown when one of the arguments provided to a method is null.
Definition: argument_null_exception.h:20
Contains xtd::static_object class.
Contains xtd fundamental types.
static new_type_t * to_ptr(current_type_t *value)
Casts a type into another type.
Definition: convert_pointer.h:126
static std::shared_ptr< new_type_t > to_shared_ptr(const std::shared_ptr< current_type_t > &value)
Casts a type into another type.
Definition: convert_pointer.h:377
static std::shared_ptr< new_type_t > to_shared_ptr(std::shared_ptr< current_type_t > &&value)
Casts a type into another type.
Definition: convert_pointer.h:420
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition: static.h:37
static std::unique_ptr< new_type_t > to_unique_ptr(std::unique_ptr< current_type_t > &value)
Casts a type into another type.
Definition: convert_pointer.h:334
static new_type_t * to_ptr(current_type_t &value)
Casts a type into another type.
Definition: convert_pointer.h:159
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Represents API to convert pointers.
Definition: convert_pointer.h:28
static const type_t * to_ptr(const type_t *value)
Casts a type into another type.
Definition: convert_pointer.h:77
#define csf_
Provides information about the current stack frame.
Definition: current_stack_frame.h:30
static const type_t * to_ptr(const type_t &value)
Casts a type into another type.
Definition: convert_pointer.h:45
static const new_type_t & to_ref(const current_type_t &value)
Casts a type into another type.
Definition: convert_pointer.h:244
static new_type_t & to_ref(current_type_t *value)
Casts a type into another type.
Definition: convert_pointer.h:311
static const new_type_t * to_ptr(const current_type_t &value)
Casts a type into another type.
Definition: convert_pointer.h:143
static const new_type_t * to_ptr(const current_type_t *value)
Casts a type into another type.
Definition: convert_pointer.h:109
static const new_type_t & to_ref(const current_type_t *value)
Casts a type into another type.
Definition: convert_pointer.h:288
static std::unique_ptr< new_type_t > to_unique_ptr(std::unique_ptr< current_type_t > &&value)
Casts a type into another type.
Definition: convert_pointer.h:355
static const type_t & to_ref(const type_t &value)
Casts a type into another type.
Definition: convert_pointer.h:176
Contains std::any type and std::bad_any_cast exception.
Contains xtd::argument_null_exception exception.
static std::shared_ptr< new_type_t > to_shared_ptr(std::shared_ptr< current_type_t > &value)
Casts a type into another type.
Definition: convert_pointer.h:398
static type_t * to_ptr(type_t &value)
Casts a type into another type.
Definition: convert_pointer.h:61
static new_type_t & to_ref(current_type_t &value)
Casts a type into another type.
Definition: convert_pointer.h:266
The exception that is thrown for invalid casting or explicit conversion.
Definition: invalid_cast_exception.h:18
static type_t & to_ref(type_t *value)
Casts a type into another type.
Definition: convert_pointer.h:226
Contains xtd::invalid_cast_exception exception.
#define unused_
It may be used to suppress the "unused variable" or "unused local typedefs" compiler warnings when th...
Definition: unused.h:30
static type_t & to_ref(type_t &value)
Casts a type into another type.
Definition: convert_pointer.h:193
static type_t * to_ptr(type_t *value)
Casts a type into another type.
Definition: convert_pointer.h:93
static const type_t & to_ref(const type_t *value)
Casts a type into another type.
Definition: convert_pointer.h:209
Contains unused_ keyword.