However, after I changed the test to the following code then it passed:
TEST_CASE("max and min")
{
using namespace std::literals;
auto length_compare = [](const auto& x1, const auto& x2)
{
return x1.length() < x2.length();
};
REQUIRE(min("undiscriminativeness"s, "vermin"s, length_compare) == "vermin");
REQUIRE(max("maxim"s, "ultramaximal"s, length_compare) == "ultramaximal");
const string str1 = "minimaxes"s;
const string str2 = "maximin"s;
const auto result = minmax(str1, str2, length_compare);
REQUIRE(result.first == "maximin");
REQUIRE(result.second == "minimaxes");
}
Notice the main change:
const string str1 = "minimaxes"s;
const string str2 = "maximin"s;
const auto result = minmax(str1, str2, length_compare);
It seems to not like the literal string values "minimaxes"s and "maximin"s and wants them to be assigned to variables. Hence the above code change.
This seems a bit odd to me (the fact that it won't accept literals etc). I'm not sure why it's designed to behave this way.
(PS: I'm using C++17 in Visual Studio 2019, using Microsoft's compiler, not clang, in case that's relevant.)
However, after I changed the test to the following code then it passed:
Notice the main change:
It seems to not like the literal string values "minimaxes"s and "maximin"s and wants them to be assigned to variables. Hence the above code change.
This seems a bit odd to me (the fact that it won't accept literals etc). I'm not sure why it's designed to behave this way.
(PS: I'm using C++17 in Visual Studio 2019, using Microsoft's compiler, not clang, in case that's relevant.)