On Fri, Nov 23, 2018 at 9:48 PM Richard Hodges via Boost < boost@lists.boost.org> wrote:
On Fri, 23 Nov 2018 at 20:59, Emil Dotchevski via Boost < boost@lists.boost.org> wrote:
On Thu, Nov 22, 2018 at 12:56 AM Jayesh Badwaik via Boost < boost@lists.boost.org> wrote:
On Monday, 19 November 2018 21:02:55 CET Emil Dotchevski via Boost
In that context there are probably legal reason for zero-warning policy, but it is not true that lack of warnings means fewer errors, in fact it could easily lead to more errors. For example warnings about implicit conversions are frequently "fixed" by replacing the implicit conversion with explicit conversion (cast). But the two are semantically very different, and therefore one of them is incorrect, and very likely
wrote: that
is
the explicit one.
Didn't know that. Can I see an example where the explicit warning is incorrect as opposed to implicit warning?
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() )
Better yet, provide a little library boilerplate and make the conversion explicit, correct and checkable at compile time:
void g( int x ) { using result_type = decltype(f()); if(auto x_ = convert(to_type
, x) ; x_ < f()) { foo(); } }
No, thank you, I prefer if( x < f() )