C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Using -1 as the max value for an unsigned integer

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Fri, 18 Jul 2025 14:26:44 +0300
On Fri, 18 Jul 2025 at 12:15, Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
> I wonder could we standardise some shorthand for this? We already have
> nullptr_t and nullptr, so maybe we could have _Max_t and _Max?

That's std::nullptr_t. Other than that, never gonna happen, the idea
with its motivation is just completely DoA.
You can shorten namespaced things locally. And it's doubly never gonna
happen that we'd stomp on names that
we have promised to never ever stomp over, including _Capitals. Those
are reserved for the implementation,
and WE MEAN IT.

>
> So it would become:
>
> size_t n = my_string.find("bla bla");
> if ( _Max == n ) DoSomething();

Yes, stash a
using Max = std::whatever_thing;
in front of that code.

> And of course in our own classes we could do:
>
> bool MyClass::operator==( _Max_t ) { . . . }
> MyClass &MyClass::operator=( _Max_t ) { . . . }

Completely pointless, and without actual plausible rationale. Nothing
whatsoever prevents using a namespaced identifier
in such contexts, and nothing whatsoever even makes it unambiguously cumbersome.

Received on 2025-07-18 11:26:59