#include <xtd/as>
#include <xtd/console>
#include <xtd/convert>
#include <xtd/random>
auto main() -> int {
double d = 41.6;
int i1 = convert::to_int32(d);
int i2 = as<int>(d);
console::write_line("d = {0}, convert::to_int32(d) = {1}, as<int>(d) = {2}", d, i1, i2);
int i = 42;
string s1 = convert::to_string(i);
string s2 = as<string>(i);
console::write_line("i = {0}, convert::to_string(i) = {1}, as<string>(i) = {2}", i, s1, s2);
std::any a = "string";
s1 = convert::to_string(a);
s2 = as<string>(a);
console::write_line("a = {0}, convert::to_string(a) = {1}, as<string>(a) = {2}", a, s1, s2);
console::write_line("value = {0}, as<string>(value) = {1}", *value, *value2);
try {
console::write_line("as<string>(rand) = {0}", as<string>(rand));
console::write_line("Bad cast : {0} !", e.message());
}
if (str == nullptr)
console::write_line("Bad cast!");
}
The exception that is thrown for invalid casting or explicit conversion.
Definition invalid_cast_exception.h:19
Represents a pseudo-random number generator, a device that produces a sequence of numbers that meet c...
Definition random.h:40
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.h:27
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10