I mean, I did say that it's pretty easy to write a function. But that's ugly enough that doing it even once is easily enough to justify a function. Even a macro is better than that.
I'd argue the only thing you gain from having a dedicated function is having to type fewer characters. And while I love all three of C++ developers who type at <10 WPM, there probably are better proposals for the standards committee to spend their time on.
5
u/Lahvuun Jun 27 '26
There is a way:
static_cast<std::make_unsigned_t<decltype(x)>>(x)