I think the problem is that the string is not a base type. std::string
is a specialization of the template, in particular std::basic_string<char>
So operator <
is defined as
template <class CharT, class Traits, class Allocator> bool operator< (const std::basic_string<CharT, Traits, Allocator> &_Left, const std::basic_string<CharT, Traits, Allocator> &_Right);
He will work with:
auto tmp = (static_cast<std::string>(a) < static_cast<std::string>(b));
Then operator <
becomes:
bool std::operator< <char, std::char_traits<char>, std::allocator<char>>(const std::string &_Left, const std::string &_Right)
source share