C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Integer overflow arithmetic

From: Tiago Freire <tmiguelf_at_[hidden]>
Date: Sat, 17 Feb 2024 10:38:03 +0000
Hi Jan,

> On further thought, it seems like your function is exactly equivalent to:
> static_cast<T>(x) == x
> Can you really argue that this expression is sufficiently common and sufficiently annoying to warrant a new function in the standard library? What I'm getting at is that you need rationale for all the specifics, and whether each of these functions has a right to exist.

I should have checked this; it is entirely my fault.
I had presented a possible implementation for it, but it turns out it was wrong, a working implementation that would behave correctly is much more complicated:
https://godbolt.org/z/79YK4c6xe
Thus, explaining why (static_cast<T>(x) == x) wouldn't work, and why it is annoying enough that warrants being written on someone's behalf.

Received on 2024-02-17 10:38:07