5#if !defined(__XTD_CORE_INTERNAL__)
6#error "Do not include this file: Internal use only"
13 template<
class type_t,
class bool_t>
14 struct __enum_any_object__ {};
16 template<
class type_t>
17 struct __enum_any_object__<type_t, std::true_type> {
18 type_t operator()(
const any_object& o)
const {
return as<enum_object<type_t>>(
o.value());}
21 template<
class type_t>
22 struct __enum_any_object__<type_t, std::false_type> {
26 template<
class type_t,
class bool_t>
27 struct __polymorphic_any_object__ {};
29 template<
class type_t>
30 struct __polymorphic_any_object__<type_t, std::true_type> {
31 type_t operator()(
const any_object& o)
const {
return as<type_t>(
o.value());}
34 template<
class type_t>
35 struct __polymorphic_any_object__<type_t, std::false_type> {
36 type_t operator()(
const any_object& o)
const {
return __enum_any_object__<type_t, typename std::is_enum<type_t>::type> {}(
o);}
58 template<
class type_t>
60 if (
is<
box<type_t>>(
o.value()))
return as<box<type_t>>(
o.value()).value;
61 return __polymorphic_any_object__<type_t, typename std::is_polymorphic<type_t>::type> {}(
o);
64 template<
class type_t>
65 type_t
as(
const any_object&
o) {
66 if (
is<box<type_t>>(
o.value()))
return as<box<type_t>>(
o.value()).value;
67 return __polymorphic_any_object__<type_t, typename std::is_polymorphic<type_t>::type> {}(
o);
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.hpp:28
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
@ invalid_cast
The cast is not valid.
bool is(std::any value)
Checks if the result of an expression is compatible with a given type.
Definition is.hpp:365
type_t as(any_object &o)
Casts a type into another type.
Definition __as_any_object.hpp:59
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Represents a boxed object.
Definition box.hpp:56