#include <xtd/xtd>
struct foo : icomparable<foo>, iequatable<foo>, ihashable, istringable {
foo() = default;
foo(int value) : value {value} {}
int value = 0;
int32 compare_to(const foo& other) const noexcept override {return value - other.value;}
size get_hash_code() const noexcept override {return hash_code::combine(value);}
bool equals(const foo& other) const noexcept override {return value == other.value;}
string to_string() const noexcept override {return string::format("{}", value);}
};
namespace std {
template<>
struct hash<foo> {
size_t operator()(const foo&) {return 0;}
};
}
template<typename type_t>
string get_boxed_info(const type_t& value) {
auto boxed_value =
boxing(value);
return string::format(
"[type = {}, boxed type = {}, value = {}]",
typeof_(value),
typeof_(boxed_value), boxed_value.to_string());
}
auto main() -> int {
console::write_line(get_boxed_info(42));
console::write_line(get_boxed_info(42.84));
console::write_line(get_boxed_info(true));
console::write_line(get_boxed_info(day_of_week::saturday));
console::write_line(get_boxed_info("A string"));
console::write_line(get_boxed_info(U"A u32 string"));
console::write_line(get_boxed_info(date_time::now()));
console::write_line(get_boxed_info(foo(42)));
}
#define typeof_
Used to obtain the type object of a specified type or object.
Definition typeof.hpp:45
auto boxing(const type_t &value) noexcept
Allows to box an object.
Definition boxing.hpp:53