13template<
typename new_type_t,
typename current_type_t>
14new_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) {
335 auto ptr = value.release();
337 return std::unique_ptr<new_type_t>(__convert_value__<new_type_t>(ptr));
338 }
catch (
const std::exception&
e) {
339 value = std::unique_ptr<current_type_t>(ptr);
356 template<
typename new_type_t,
typename current_type_t>
357 static std::unique_ptr<new_type_t>
to_unique_ptr(std::unique_ptr<current_type_t>&& value) {
358 auto ptr = value.release();
360 return std::unique_ptr<new_type_t>(__convert_value__<new_type_t>(ptr));
361 }
catch (
const std::exception&
e) {
362 value = std::unique_ptr<current_type_t>(ptr);
380 template<
typename new_type_t,
typename current_type_t>
381 static std::shared_ptr<new_type_t>
to_shared_ptr(
const std::shared_ptr<current_type_t>& value) {
383 unused_(
dynamic_cast<new_type_t&
>(*value.get()));
384 }
catch (
const std::exception&
e) {
387 return std::dynamic_pointer_cast<new_type_t>(value);
401 template<
typename new_type_t,
typename current_type_t>
402 static std::shared_ptr<new_type_t>
to_shared_ptr(std::shared_ptr<current_type_t>& value) {
404 unused_(
dynamic_cast<new_type_t&
>(*value.get()));
405 }
catch (
const std::exception&
e) {
408 return std::dynamic_pointer_cast<new_type_t>(value);
423 template<
typename new_type_t,
typename current_type_t>
424 static std::shared_ptr<new_type_t>
to_shared_ptr(std::shared_ptr<current_type_t>&& value) {
426 unused_(
dynamic_cast<new_type_t&
>(*value.get()));
427 }
catch (
const std::exception&
e) {
431 return std::dynamic_pointer_cast<new_type_t>(std::move(value));
Contains std::any type and std::bad_any_cast exception.
Contains xtd::argument_null_exception exception.
The exception that is thrown when one of the arguments provided to a method is null.
Definition argument_null_exception.h:20
Represents API to convert pointers.
Definition convert_pointer.h:28
The exception that is thrown for invalid casting or explicit conversion.
Definition invalid_cast_exception.h:18
#define unused_
It may be used to suppress the "unused variable" or "unused local typedefs" compiler warnings when th...
Definition unused.h:30
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.h:37
#define csf_
Provides information about the current stack frame.
Definition current_stack_frame.h:30
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 type_t * to_ptr(const type_t *value)
Casts a type into another type.
Definition convert_pointer.h:77
static type_t & to_ref(type_t *value)
Casts a type into another type.
Definition convert_pointer.h:226
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:357
static const new_type_t * to_ptr(const current_type_t *value)
Casts a type into another type.
Definition convert_pointer.h:109
static new_type_t & to_ref(current_type_t *value)
Casts a type into another type.
Definition convert_pointer.h:311
static type_t * to_ptr(type_t *value)
Casts a type into another type.
Definition convert_pointer.h:93
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:402
static new_type_t * to_ptr(current_type_t &value)
Casts a type into another type.
Definition convert_pointer.h:159
static const type_t & to_ref(const type_t *value)
Casts a type into another type.
Definition convert_pointer.h:209
static const type_t & to_ref(const type_t &value)
Casts a type into another type.
Definition convert_pointer.h:176
static new_type_t * to_ptr(current_type_t *value)
Casts a type into another type.
Definition convert_pointer.h:126
static const new_type_t & to_ref(const current_type_t &value)
Casts a type into another type.
Definition convert_pointer.h:244
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:381
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::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:424
static type_t & to_ref(type_t &value)
Casts a type into another type.
Definition convert_pointer.h:193
static const type_t * to_ptr(const type_t &value)
Casts a type into another type.
Definition convert_pointer.h:45
static new_type_t & to_ref(current_type_t &value)
Casts a type into another type.
Definition convert_pointer.h:266
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 type_t * to_ptr(type_t &value)
Casts a type into another type.
Definition convert_pointer.h:61
Contains xtd::invalid_cast_exception exception.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::static_object class.
Contains xtd fundamental types.
Contains unused_ keyword.