Show how to use format xtd::format class with specified formatting.
#include <xtd/format_exception>
#include <xtd/ustring>
using namespace std;
public:
const ustring& name()
const noexcept {
return name_;}
const ustring& rank()
const noexcept {
return rank_;}
if (fmt == "F") return name_ + " (" + rank_ + ")";
if (fmt == "N") return name_;
if (fmt == "R") return rank_;
}
friend ostream& operator <<(ostream& os,
const character& value) noexcept {
return os << value.to_string();}
private:
};
template<>
auto main()->int {
auto c =
character {
"Jean-Luc Picard",
"Captain"};
cout << ustring::format(
"{}",
c) << endl;
cout << ustring::format(
"{:F}",
c) << endl;
cout << ustring::format(
"{:N}",
c) << endl;
cout << ustring::format(
"{:R}",
c) << endl;
}