The FastFormat library works like this:
string example;
fastformat::fmt(example, "I am asking {0} question on {1}", 1, "stackoverflow");
It also claims "100% type-safety". I can understand how other libraries such as boost::format
achieve that by overloading operator%
, something I do fairly often with my code too.
But if I was able to use comma instead it would be less surprising to other programmers. I'm really curious to know how I can guarantee type safety without the templated operator overloading trick.
Aside note: in case you are wondering what's the "templated operator overloading trick", this is how boost::format works (mostly):
struct Test
{
template<class T>
Test& operator%(const T& what) { cout << what << "\n" /* Example */; return *this; }
};
Test() % 5 % "abc";