6#if !defined(__XTD_CORE_INTERNAL__)
7#error "Do not include this file: Internal use only"
11#define __XTD_STD_INTERNAL__
13#undef __XTD_STD_INTERNAL__
35 template<
typename new_type_t>
36 new_type_t
as(std::any value) {
38 return std::any_cast<new_type_t>(value);
39 }
catch (
const std::exception&
e) {
61 template<
typename new_type_t>
62 new_type_t
as(
bool value) {
63 return static_cast<new_type_t
>(value);
83 template<
typename new_type_t>
85 return static_cast<new_type_t
>(value);
105 template<
typename new_type_t>
106 new_type_t
as(
char value) {
107 return static_cast<new_type_t
>(value);
110#if defined(__xtd__cpp_lib_char8_t)
128 template<
typename new_type_t>
130 return static_cast<new_type_t
>(value);
151 template<
typename new_type_t>
153 return static_cast<new_type_t
>(value);
173 template<
typename new_type_t>
175 return static_cast<new_type_t
>(value);
195 template<
typename new_type_t>
197 return static_cast<new_type_t
>(value);
217 template<
typename new_type_t>
219 return static_cast<new_type_t
>(value);
239 template<
typename new_type_t>
240 new_type_t
as(
double value) {
241 return static_cast<new_type_t
>(value);
261 template<
typename new_type_t>
262 new_type_t
as(
float value) {
263 return static_cast<new_type_t
>(value);
283 template<
typename new_type_t>
285 return static_cast<new_type_t
>(value);
305 template<
typename new_type_t>
307 return static_cast<new_type_t
>(value);
327 template<
typename new_type_t>
329 return static_cast<new_type_t
>(value);
349 template<
typename new_type_t>
351 return static_cast<new_type_t
>(value);
371 template<
typename new_type_t>
373 return static_cast<new_type_t
>(value);
393 template<
typename new_type_t>
395 return static_cast<new_type_t
>(value);
415 template<
typename new_type_t>
417 return static_cast<new_type_t
>(value);
437 template<
typename new_type_t>
439 return static_cast<new_type_t
>(value);
459 template<
typename new_type_t>
461 return static_cast<new_type_t
>(value);
482 template<
typename new_type_t>
485 return dynamic_cast<const new_type_t&
>(value);
486 }
catch (
const std::exception&
e) {
489 throw std::bad_cast();
510 template<
typename new_type_t>
513 return dynamic_cast<new_type_t&
>(value);
514 }
catch (
const std::exception&
e) {
517 throw std::bad_cast();
521 template<
typename new_type_t>
523 throw invalid_cast_exception {};
525 template<
typename new_type_t>
527 throw invalid_cast_exception {};
529 template<
typename new_type_t>
531 throw invalid_cast_exception {};
533 template<
typename new_type_t>
535 throw invalid_cast_exception {};
537 template<
typename new_type_t>
539 throw invalid_cast_exception {};
541 template<
typename new_type_t>
543 throw invalid_cast_exception {};
545 template<
typename new_type_t>
547 throw invalid_cast_exception {};
549 template<
typename new_type_t>
551 throw invalid_cast_exception {};
553 template<
typename new_type_t>
555 throw invalid_cast_exception {};
557 template<
typename new_type_t>
559 throw invalid_cast_exception {};
561 template<
typename new_type_t>
563 throw invalid_cast_exception {};
580 template<
typename new_type_t>
581 new_type_t
as(
const std::string& value) {
583 return dynamic_cast<const new_type_t&
>(value);
584 }
catch (
const std::exception&
e) {
587 throw std::bad_cast();
603 template<
typename new_type_t>
604 new_type_t
as(std::string& value) {
606 return dynamic_cast<new_type_t&
>(value);
607 }
catch (
const std::exception&
e) {
610 throw std::bad_cast();
613#if defined(__xtd__cpp_lib_char8_t)
627 template<
typename new_type_t>
628 new_type_t
as(
const std::u8string& value) {
630 return dynamic_cast<const new_type_t&
>(value);
631 }
catch (
const std::exception&
e) {
634 throw std::bad_cast();
650 template<
typename new_type_t>
651 new_type_t
as(std::u8string& value) {
653 return dynamic_cast<new_type_t&
>(value);
654 }
catch (
const std::exception&
e) {
657 throw std::bad_cast();
674 template<
typename new_type_t>
675 new_type_t
as(
const std::u16string& value) {
677 return dynamic_cast<const new_type_t&
>(value);
678 }
catch (
const std::exception&
e) {
681 throw std::bad_cast();
697 template<
typename new_type_t>
698 new_type_t
as(std::u16string& value) {
700 return dynamic_cast<new_type_t&
>(value);
701 }
catch (
const std::exception&
e) {
704 throw std::bad_cast();
720 template<
typename new_type_t>
721 new_type_t
as(
const std::u32string& value) {
723 return dynamic_cast<const new_type_t&
>(value);
724 }
catch (
const std::exception&
e) {
727 throw std::bad_cast();
743 template<
typename new_type_t>
744 new_type_t
as(std::u32string& value) {
746 return dynamic_cast<new_type_t&
>(value);
747 }
catch (
const std::exception&
e) {
750 throw std::bad_cast();
766 template<
typename new_type_t>
767 new_type_t
as(
const std::wstring& value) {
769 return dynamic_cast<const new_type_t&
>(value);
770 }
catch (
const std::exception&
e) {
773 throw std::bad_cast();
789 template<
typename new_type_t>
790 new_type_t
as(std::wstring& value) {
792 return dynamic_cast<new_type_t&
>(value);
793 }
catch (
const std::exception&
e) {
796 throw std::bad_cast();
816 template<
typename new_type_t>
817 new_type_t
as(
const char* value) {
818 return reinterpret_cast<new_type_t
>(value);
838 template<
typename new_type_t>
839 new_type_t
as(
char* value) {
840 return reinterpret_cast<new_type_t
>(value);
843#if defined(__xtd__cpp_lib_char8_t)
861 template<
typename new_type_t>
863 return reinterpret_cast<new_type_t
>(value);
883 template<
typename new_type_t>
885 return reinterpret_cast<new_type_t
>(value);
906 template<
typename new_type_t>
908 return reinterpret_cast<new_type_t
>(value);
928 template<
typename new_type_t>
930 return reinterpret_cast<new_type_t
>(value);
950 template<
typename new_type_t>
952 return reinterpret_cast<new_type_t
>(value);
972 template<
typename new_type_t>
974 return reinterpret_cast<new_type_t
>(value);
994 template<
typename new_type_t>
996 return reinterpret_cast<new_type_t
>(value);
1016 template<
typename new_type_t>
1018 return reinterpret_cast<new_type_t
>(value);
Contains __xtd_std_version definitions.
Represents text as a sequence of character units.
Definition basic_string.h:79
The exception that is thrown for invalid casting or explicit conversion.
Definition invalid_cast_exception.h:19
int16_t int16
Represents a 16-bit signed integer.
Definition int16.h:23
char8_t char8
Represents a 8-bit unicode character.
Definition char8.h:27
wchar_t wchar
Represents a wide character.
Definition wchar.h:24
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
long double decimal
Represents a decimal-precision floating-point number.
Definition decimal.h:23
int64_t int64
Represents a 64-bit signed integer.
Definition int64.h:23
__ulong__ ulong
Represents a 32-bit or 64-bit unsigned integer.
Definition ulong.h:27
int8_t sbyte
Represents a 8-bit signed integer.
Definition sbyte.h:23
char16_t char16
Represents a 16-bit unicode character.
Definition char16.h:26
uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.h:23
char32_t char32
Represents a 32-bit unicode character.
Definition char32.h:26
uint64_t uint64
Represents a 64-bit unsigned integer.
Definition uint64.h:23
uint8_t byte
Represents a 8-bit unsigned integer.
Definition byte.h:23
uint16_t uint16
Represents a 16-bit unsigned integer.
Definition uint16.h:23
__slong__ slong
Represents a 32-bit or 64-bit signed integer.
Definition slong.h:27
type_t as(any_object &o)
Casts a type into another type.
Definition __as_any_object.h:57
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10