#include <xtd/xtd>
struct foo1 : icomparable<foo1>, iequatable<foo1>, istringable {
foo1() = default;
explicit foo1(int value) : value {value} {}
int value = 0;
auto compare_to(const foo1& other) const noexcept -> int32 override {return value - other.value;}
auto equals(const foo1& other) const noexcept -> bool override {return value == other.value;}
auto to_string() const noexcept -> string override {return string::format("{}", value);}
};
struct foo2 {
int value = 0;
auto operator <(const foo2& other) const noexcept -> bool {return value < other.value;}
auto operator >(
const foo2& other)
const noexcept ->
bool {
return value >
other.value;}
auto operator ==(
const foo2& other)
const noexcept ->
bool {
return value ==
other.value;}
friend auto operator <<(std::ostream& os, const foo2& value) -> std::ostream& {return os << string::format("{}", value.value);}
};
template<typename type_t>
auto get_boxed_info(const type_t& value) -> string {
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(foo1 {42}));
console::write_line(get_boxed_info(foo2 {.value = 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
@ other
The operating system is other.
Definition platform_id.hpp:60