12template<
typename new_type,
typename current_type>
13new_type* __convert_value__(current_type* value);
44 template<
typename new_type,
typename current_type>
45 [[nodiscard]]
static auto to_ptr(
const current_type* value) ->
const new_type* {
46 if (value ==
nullptr)
return nullptr;
61 template<
typename new_type,
typename current_type>
62 [[nodiscard]]
static auto to_ptr(current_type* value) -> new_type* {
63 if (value ==
nullptr)
return nullptr;
78 template<
typename new_type,
typename current_type>
79 [[nodiscard]]
static auto to_ptr(
const current_type& value) ->
const new_type* {
94 template<
typename new_type,
typename current_type>
95 [[nodiscard]]
static auto to_ptr(current_type& value) -> new_type* {
111 template<
typename new_type,
typename current_type>
127 template<
typename new_type,
typename current_type>
144 template<
typename new_type,
typename current_type>
161 template<
typename new_type,
typename current_type>
162 [[nodiscard]]
static auto to_ref(
const current_type& value) ->
const new_type& {
164 return dynamic_cast<const new_type&
>(value);
165 }
catch (
const std::exception&
e) {
183 template<
typename new_type,
typename current_type>
184 [[nodiscard]]
static auto to_ref(current_type& value) -> new_type& {
186 return dynamic_cast<new_type&
>(value);
187 }
catch (
const std::exception&
e) {
205 template<
typename new_type,
typename current_type>
206 [[nodiscard]]
static auto to_ref(
const current_type* value) ->
const new_type& {
209 return dynamic_cast<const new_type&
>(*value);
210 }
catch (
const std::exception&
e) {
228 template<
typename new_type,
typename current_type>
229 [[nodiscard]]
static auto to_ref(current_type* value) -> new_type& {
232 return dynamic_cast<new_type&
>(*value);
233 }
catch (
const std::exception&
e) {
251 template<
typename new_type,
typename 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<
typename new_type,
typename 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<
typename new_type,
typename 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<
typename new_type,
typename current_type>
333 template<
typename new_type,
typename current_type>
350 template<
typename new_type,
typename current_type>
367 template<
typename new_type,
typename current_type>
369 auto ptr = value.release();
372 }
catch (
const std::exception&
e) {
390 template<
typename new_type,
typename current_type>
392 auto ptr = value.release();
395 }
catch (
const std::exception&
e) {
414 template<
typename new_type,
typename current_type>
430 template<
typename new_type,
typename 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:38
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 auto to_ptr(const current_type *value) -> const new_type *
Casts a type into another type.
Definition convert_pointer.hpp:45
static auto to_ptr(current_type *value) -> new_type *
Casts a type into another type.
Definition convert_pointer.hpp:62
static auto to_shared_ptr(xtd::sptr< current_type > &&value) -> xtd::sptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:295
static auto to_ptr(xtd::ptr< current_type > &value) -> xtd::ptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:128
static auto to_ptr(xtd::ptr< current_type > &&value) -> xtd::ptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:145
static auto to_sptr(const xtd::sptr< current_type > &value) -> xtd::sptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:318
static auto to_shared_ptr(xtd::sptr< current_type > &value) -> xtd::sptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:273
static auto to_unique_ptr(xtd::uptr< current_type > &&value) -> xtd::uptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:391
static auto to_unique_ptr(xtd::uptr< current_type > &value) -> xtd::uptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:368
static auto to_sptr(xtd::sptr< current_type > &&value) -> xtd::sptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:351
static auto to_ptr(current_type &value) -> new_type *
Casts a type into another type.
Definition convert_pointer.hpp:95
static auto to_ref(const current_type &value) -> const new_type &
Casts a type into another type.
Definition convert_pointer.hpp:162
static auto to_ref(current_type &value) -> new_type &
Casts a type into another type.
Definition convert_pointer.hpp:184
static auto to_uptr(xtd::uptr< current_type > &value) -> xtd::uptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:415
static auto to_shared_ptr(const xtd::sptr< current_type > &value) -> xtd::sptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:252
static auto to_ref(const current_type *value) -> const new_type &
Casts a type into another type.
Definition convert_pointer.hpp:206
static auto to_ptr(const current_type &value) -> const new_type *
Casts a type into another type.
Definition convert_pointer.hpp:79
static auto to_sptr(xtd::sptr< current_type > &value) -> xtd::sptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:334
static auto to_ptr(const xtd::ptr< current_type > &value) -> xtd::ptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:112
static auto to_ref(current_type *value) -> new_type &
Casts a type into another type.
Definition convert_pointer.hpp:229
static auto to_uptr(xtd::uptr< current_type > &&value) -> xtd::uptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:431
@ 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.