diff --git a/format.hpp b/format.hpp index 6ad3d9ca..6cc98afb 100644 --- a/format.hpp +++ b/format.hpp @@ -104,17 +104,32 @@ namespace cruft::format { /// lifetime of the return value. template bound - operator () (const Args &...args) &; + operator() (const Args &...args) &; /// records a complete collection of parameters for rendering in the /// future. takes ownership of the specifiers so there is no lifetime /// requirement. template stored - operator () (const Args &...args) &&; + operator() (const Args &...args) &&; }; + template + class bound; + + template + std::string + to_string (const bound&); + + template + class stored; + + template + std::string + to_string (const bound&); + + /// parameter collection for a non-owning sequence of specifiers template class bound { @@ -124,13 +139,21 @@ namespace cruft::format { m_values {args...} { ; } + auto specifiers (void) const { return view (m_parsed.m_specifiers); } + template auto get (void) const& { return std::get (m_values); } + + operator ::std::string () const + { + return to_string (*this); + } + private: const parsed &m_parsed; std::tuple m_values; @@ -146,16 +169,24 @@ namespace cruft::format { m_values {args...} { ; } + auto specifiers (void) const& { return view {m_specifiers}; } + template const auto& get (void) const& { return std::get (m_values); } + + operator ::std::string () const + { + return to_string (*this); + } + private: std::vector m_specifiers; std::tuple m_values; @@ -164,13 +195,13 @@ namespace cruft::format { template bound - parsed::operator () (const Args &...args) & + parsed::operator() (const Args &...args) & { return bound { *this, args... }; } template stored - parsed::operator () (const Args &...args) && + parsed::operator() (const Args &...args) && { return stored { std::move (m_specifiers), args... }; }