On Mon, 26 Nov 2018 at 08:38, Emil Dotchevski via Boost < boost@lists.boost.org> wrote:
The reason is that they have the wrong mindset when approaching the problem.
They think: I get a warning, because the compiler doesn't know that this signed value is always positive, but I know that it is, so I'm going to cast, to tell the compiler that I know what I'm doing.
A better reasoning is: I'm converting a signed value to unsigned value, which will not be correct if the signed value is negative. With this in mind, you'll notice that the cast is utterly useless in catching the actual error the compiler is warning you about.
+1, the above summarizes the issue quite nicely, I think. degski -- *“If something cannot go on forever, it will stop" - Herbert Stein*