On 24/11/2018 08:58, Emil Dotchevski wrote:
I'm guessing you want an example where the explicit conversion is incorrect, and you want to use an implicit conversion even though you get a warning. Here:
unsigned f();
void g( int x ) { if( x < f() ) //warning C4018: '<': signed/unsigned mismatch { .... } }
So you change that to:
if( static_cast<unsigned>(x) < f() )
Then under refactoring both f and g get changed:
unsigned long f();
void g( long x ) { if( static_cast<unsigned>(x) < f() ) { .... } }
auto xu = std::make_unsigned_t
assert(x>=0);
That helps -- assuming that people actually check asserts, which isn't always the case.