Shows how to use xtd::any_object class.
#include <xtd/any_object>
#include <xtd/console>
#include <xtd/date_time>
 
 
  explicit foo1(int v) : value(v) {}
  int value = 0;
  
  string to_string() const noexcept override {return string::format("{}", value);}
  bool operator <(const foo1& f) const noexcept {return value < f.value;}
};
 
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;}
 
};
 
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)));
 
}
 
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.hpp:28
 
Represents an instant in time, typically expressed as a date and time of day.
Definition date_time.hpp:85
 
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:42
 
#define typeof_
Used to obtain the type object of a specified type or object.
Definition typeof.hpp:45
 
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10