C++ Logo

std-proposals

Advanced search

Re: [std-proposals] return if

From: Filip <fph2137_at_[hidden]>
Date: Thu, 15 Jan 2026 12:20:43 +0100
I made the names shorter :)

```
uint128_t GetSignatoryID(time_point birth, string_view surname, string_view forename )
   {
       return if manager.GetRegion("Sweden" ).FindRecord(birth, surname, forename );
       return if manager.GetRegion("Germany").FindRecord(birth, surname, forename );
       return if manager.GetRegion("Japan" ).FindRecord(birth, surname, forename );

       return GenerateNewID( birth, surname, forename);
   }
```

I think that this is perfectly readable, however now I think that soft_assert would be a better name.
It would do the opposite comparison to false instead of true, but the logic could be the same:
Return value of expression before it was cast to bool and compared to either true or false indicated by ‘!’.

```
uint128_t GetSignatoryID(time_point birth, string_view surname, string_view forename )
   {
       soft_assert( ! manager.GetRegion("Sweden" ).FindRecord(birth, surname, forename) );
       soft_assert( ! manager.GetRegion("Germany").FindRecord(birth, surname, forename) );
       soft_assert( ! manager.GetRegion("Japan" ).FindRecord(birth, surname, forename) );

       return GenerateNewID( birth, surname, forename);
   }
```

They look almost the same, however it is probably an easier idea to sell to both C and C++ programmers.
Easier to change to a “hard” assert, and it does basically the same action as “return if”.
The compiler can figure out in both `return if` and `soft_assert` that the ‘!’ symbol should be disregarded for the return value.

> On 15 Jan 2026, at 11:45, Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> __uint128_t GetSignatoryID( chrono::time_point date_of_birth,
> string_view primary_surname_on_birthcert, string_view
> primary_forename_on_birthcert )
> {
> return if manager.GetRegion("Sweden" ).FindRecord(
> date_of_birth, primary_surname_on_birthcert,
> primary_forename_on_birthcert );
> return if manager.GetRegion("Germany").FindRecord(
> date_of_birth, primary_surname_on_birthcert,
> primary_forename_on_birthcert );
> return if manager.GetRegion("Japan" ).FindRecord(
> date_of_birth, primary_surname_on_birthcert,
> primary_forename_on_birthcert );
>
> return GenerateNewID( date_of_birth,
> primary_surname_on_birthcert, primary_forename_on_birthcert );
> }


Received on 2026-01-15 11:21:00