#include <xtd/xtd>
struct foo1 : public object, public icomparable<foo1>, public iequatable<foo1> {
explicit foo1(int v) : value(v) {}
int value = 0;
string to_string() const noexcept override {return string::format("{}", value);}
bool equals(const object& o) const noexcept override {return is<foo1>(o) && equals(static_cast<const foo1&>(o));}
bool equals(const foo1& f) const noexcept override {return value == f.value;}
int32 compare_to(const foo1& f) const noexcept override {return value < f.value ? -1 : value > f.value ? 1 : 0;}
};
struct foo2 {
int value = 0;
bool operator ==(const foo2& f) const noexcept {return value == f.value;}
bool operator <(
const foo2& f)
const noexcept {
return value <
f.value;}
bool operator >(
const foo2& f)
const noexcept {
return value >
f.value;}
};
template<>
std::string
xtd::to_string(
const foo2& value,
const std::string& fmt,
const std::locale& loc) {
return xtd::int32_object {value.value}.to_string(fmt, loc);}
template<>
struct std::hash<foo2> {
};
auto main() -> int {
console::write_line(
"a = {} => {} ({})", a, as<string>(a),
typeof_(as<string>(a)));
console::write_line(
"a = {} => {} ({})", a, as<date_time>(a),
typeof_(as<date_time>(a)));
console::write_line(
"a = {} => {} ({})", a, as<int32>(a),
typeof_(as<int32>(a)));
console::write_line(
"a = {} => {} ({})", a, as<double>(a),
typeof_(as<double>(a)));
console::write_line(
"a = {} => {} ({})", a, as<foo1>(a),
typeof_(as<foo1>(a)));
console::write_line(
"a = {} => {} ({})", a,
"NA",
typeof_(as<foo2>(a)));
a = day_of_week::wednesday;
console::write_line(
"a = {} => {} ({})", a, as<day_of_week>(a),
typeof_(as<day_of_week>(a)));
}
static xtd::size combine(args_t... values) noexcept
Combines values into a hash code.
Definition hash_code.hpp:70
@ date_time
Write the date and time.
Definition trace_options.hpp:31
#define typeof_
Used to obtain the type object of a specified type or object.
Definition typeof.hpp:45
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
box_integer< int32 > int32_object
Represent a boxed int32.
Definition int32_object.hpp:29
@ a
The A key.
Definition console_key.hpp:88
@ f
The F key.
Definition console_key.hpp:98
string to_string() const noexcept override
Returns the string representation of this xtd::read_only_span <type_t> object.
Definition read_only_span.hpp:375