I have seen many printf type implementations, but most of them use an exception to raise type errors.
As an exercise, I used a formatting prototype like printf using string literals, and it seems to solve all the problems with the old, good printf family (except for using a format read from an external source, which is always unsafe).
Example:
int main(int argc, char* argv[])
{
std::cout << "const char*: %s, std::string: %s\n"_format("ONE", std::string{"TWO"});
std::cout << "user defined: %*\n"_format(std::complex<int>{1, 2});
std::cout << "hex: 0x%x, int: %d\n"_format(16, 123);
std::cout << "double.2: %.2f, double: %f\n"_format(13.123123, 12.1);
std::string s = "p(%d, %d)\n"_format(123, 234);
std::cout << s;
}
Full, dirty and not full or optimized code here
.s
, , const
, , , argv
. count , .
, : - , , ++?