#include <xtd/boxing>
#include <xtd/console>
#include <xtd/date_time>
#include <xtd/day_of_week>
#include <xtd/typeof>
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)));
}
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition ihashable.hpp:21
Provides a way to represent the current object as a string.
Definition istringable.hpp:23
#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:52
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10