10template<
typename new_type,
typename current_type>
11new_type* __convert_value__(current_type* value);
42 template<
typename new_type,
typename current_type>
43 [[nodiscard]]
static auto to_ptr(
const current_type* value) ->
const new_type* {
44 if (value ==
nullptr)
return nullptr;
59 template<
typename new_type,
typename current_type>
60 [[nodiscard]]
static auto to_ptr(current_type* value) -> new_type* {
61 if (value ==
nullptr)
return nullptr;
76 template<
typename new_type,
typename current_type>
77 [[nodiscard]]
static auto to_ptr(
const current_type& value) ->
const new_type* {
92 template<
typename new_type,
typename current_type>
93 [[nodiscard]]
static auto to_ptr(current_type& value) -> new_type* {
109 template<
typename new_type,
typename current_type>
125 template<
typename new_type,
typename current_type>
142 template<
typename new_type,
typename current_type>
159 template<
typename new_type,
typename current_type>
160 [[nodiscard]]
static auto to_ref(
const current_type& value) ->
const new_type& {
162 return dynamic_cast<const new_type&
>(value);
163 }
catch (
const std::exception&
e) {
181 template<
typename new_type,
typename current_type>
182 [[nodiscard]]
static auto to_ref(current_type& value) -> new_type& {
184 return dynamic_cast<new_type&
>(value);
185 }
catch (
const std::exception&
e) {
203 template<
typename new_type,
typename current_type>
204 [[nodiscard]]
static auto to_ref(
const current_type* value) ->
const new_type& {
207 return dynamic_cast<const new_type&
>(*value);
208 }
catch (
const std::exception&
e) {
226 template<
typename new_type,
typename current_type>
227 [[nodiscard]]
static auto to_ref(current_type* value) -> new_type& {
230 return dynamic_cast<new_type&
>(*value);
231 }
catch (
const std::exception&
e) {
249 template<
typename new_type,
typename current_type>
252 [[maybe_unused]]
auto result =
dynamic_cast<new_type&
>(*value.get());
253 }
catch (
const std::exception&
e) {
256 return std::dynamic_pointer_cast<new_type>(value.pointer());
270 template<
typename new_type,
typename current_type>
273 [[maybe_unused]]
auto& result =
dynamic_cast<new_type&
>(*value.get());
274 }
catch (
const std::exception&
e) {
277 return std::dynamic_pointer_cast<new_type>(value.pointer());
292 template<
typename new_type,
typename current_type>
295 [[maybe_unused]]
auto& result =
dynamic_cast<new_type&
>(*value.get());
296 }
catch (
const std::exception&
e) {
300 return std::dynamic_pointer_cast<new_type>(std::move(value.pointer()));
315 template<
typename new_type,
typename current_type>
331 template<
typename new_type,
typename current_type>
348 template<
typename new_type,
typename current_type>
365 template<
typename new_type,
typename current_type>
367 auto ptr = value.release();
370 }
catch (
const std::exception&
e) {
388 template<
typename new_type,
typename current_type>
390 auto ptr = value.release();
393 }
catch (
const std::exception&
e) {
412 template<
typename new_type,
typename current_type>
428 template<
typename new_type,
typename current_type>
Contains xtd::any type and std::bad_any_cast exception.
Represents API to convert pointers.
Definition convert_pointer.hpp:27
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:43
static auto to_ptr(current_type *value) -> new_type *
Casts a type into another type.
Definition convert_pointer.hpp:60
static auto to_shared_ptr(xtd::sptr< current_type > &&value) -> xtd::sptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:293
static auto to_ptr(xtd::ptr< current_type > &value) -> xtd::ptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:126
static auto to_ptr(xtd::ptr< current_type > &&value) -> xtd::ptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:143
static auto to_sptr(const xtd::sptr< current_type > &value) -> xtd::sptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:316
static auto to_shared_ptr(xtd::sptr< current_type > &value) -> xtd::sptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:271
static auto to_unique_ptr(xtd::uptr< current_type > &&value) -> xtd::uptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:389
static auto to_unique_ptr(xtd::uptr< current_type > &value) -> xtd::uptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:366
static auto to_sptr(xtd::sptr< current_type > &&value) -> xtd::sptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:349
static auto to_ptr(current_type &value) -> new_type *
Casts a type into another type.
Definition convert_pointer.hpp:93
static auto to_ref(const current_type &value) -> const new_type &
Casts a type into another type.
Definition convert_pointer.hpp:160
static auto to_ref(current_type &value) -> new_type &
Casts a type into another type.
Definition convert_pointer.hpp:182
static auto to_uptr(xtd::uptr< current_type > &value) -> xtd::uptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:413
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:250
static auto to_ref(const current_type *value) -> const new_type &
Casts a type into another type.
Definition convert_pointer.hpp:204
static auto to_ptr(const current_type &value) -> const new_type *
Casts a type into another type.
Definition convert_pointer.hpp:77
static auto to_sptr(xtd::sptr< current_type > &value) -> xtd::sptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:332
static auto to_ptr(const xtd::ptr< current_type > &value) -> xtd::ptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:110
static auto to_ref(current_type *value) -> new_type &
Casts a type into another type.
Definition convert_pointer.hpp:227
static auto to_uptr(xtd::uptr< current_type > &&value) -> xtd::uptr< new_type >
Casts a type into another type.
Definition convert_pointer.hpp:429
@ e
The E key.
Definition console_key.hpp:96
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.