Consider this code snippet:
bool foo(const std::string& s) { return s == \"hello\"; // comparing against a const char* literal } bool bar(const std::str
No, compare() does not require construction of a std::string for const char* operands.
compare()
std::string
const char*
You're using overload #4 here.
The comparison to string literal is the "free" version you're looking for. Instantiating a std::string here is completely unnecessary.