C++ Logo

std-proposals

Advanced search

Re: [std-proposals] return if

From: Thiago Macieira <thiago_at_[hidden]>
Date: Tue, 13 Jan 2026 13:32:59 -0800
On Tuesday, 13 January 2026 10:02:48 Pacific Standard Time Frederick Virchanza
Gotham via Std-Proposals wrote:
> Anyway it would be more readable as:
>
> return false if SomeFunction();

No, it wouldn't, because of this:

> In this context the 'false' really means 'inverted'

The above should be identical to:
    if (SomeFunction) return false;

Anything different is a recipe for misunderstanding.

If you want to find a "return inverted", find another syntax. If I read "return
false", I expect the function to return false (or the return type constructed
from false), not anything different. The trailing portion should not affect it.

> No new functionality added but it's handy and looks nice.

It does not look nice. It looks unreadable and prone to confusion.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-01-13 21:33:05