P0608r3, as adopted in San Diego 2018, addresses several surprising type conversion choices that occur during overload resolution in the use of std::variant.
However, that has led to a split between how things end up working between "classic" overload resolution, and overload resolution for std::variant. It feels like this was not the intent, and certainly leads to a how-to-teach problem.
For instance.
Before P0608 - behaviour is consistent, but surprising
int func( string )
{
return 42;
}
int func( bool )
{
return 19;
}
int x = func( "Hello" ); // x is 19
int y= func( "Hello"s ); // x is 42
std::variant< bool, string > z;
z = "Hello World"; // z holds a bool
Now, with P0608 in place, we have conflicting behaviour, but the variant case is "sane".
int func( string )
{
return 42;
}
int func( bool )
{
return 19;
}
int x = func( "Hello" ); // x is 19
int y= func( "Hello"s ); // x is 42
std::variant< bool, string > z;
z = "Hello World"; // z holds a string
Given where we are in the cycle, I don't know if the correct thing to do is to suggest that we fix the core language, undo P0608, do nothing, or some fourth option.
Kind Rgds
Staffan Tj.