Simplifying string confirmations
While I was writing the code for this chapter, I ran into a problem confirming string data types that reminded me of how we added support for confirming strings in Chapter 5, Adding More Confirm Types. The motivating factor from Chapter 5 was to get the code to compile because we can’t pass std::string
to a std::to_string
function. I’ll briefly explain the problem again here.
I’m not sure of the exact reasons, but I think that the C++ standard library designers felt there was no need to provide an overload of std::to_string
that accepts std::string
because no conversion is needed. A string is already a string! Why convert something into what it already is?
Maybe this decision was on purpose or maybe it was an oversight. But it sure would have helped to have a string conversion into a string for template functions that need to convert their generic types into strings. That’s because, without the overload, we have to...