#include <xtd/console>
#include <xtd/environment>
#include <xtd/register_any_stringer>
#include <xtd/string>
#include <xtd/unregister_any_stringer>
class character {
public:
character(const string& name, const string& rank) noexcept : name_(name), rank_(rank) {}
const string& name() const noexcept {return name_;}
const string& rank() const noexcept {return rank_;}
string to_string()
const noexcept {
return name_ +
" (" + rank_ +
")";}
private:
string name_;
string rank_;
};
auto main() -> int {
auto value = std::make_any<int>(42);
value = std::make_any<string>("Star Trek: The Next Generation");
value = std::make_any<character>("Jean-Luc Picard", "Captain");
unregister_any_stringer<character>();
}
static std::ostream out
Gets the standard output stream. A std::basic_ostream<char_t> that represents the standard output str...
Definition console.hpp:52
static xtd::string new_line() noexcept
Gets the newline string defined for this environment.
void register_any_stringer(const function_t &func)
Register an any stringer method for a specified type.
Definition register_any_stringer.hpp:38
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
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