C++ Logo

std-proposals

Advanced search

Re: [std-proposals] return if

From: Thiago Macieira <thiago_at_[hidden]>
Date: Tue, 13 Jan 2026 07:55:20 -0800
On Tuesday, 13 January 2026 07:20:02 Pacific Standard Time Frederick Virchanza
Gotham via Std-Proposals wrote:
> SomeFunction could return an Lvalue, a PRvalue, or an Xvalue, for example:
>
> mutex SomeFunction(void);
> mutex &SomeFunction(void);
> mutex &&SomeFunction(void);
>
> This is why we need:
>
> decltype(SomeFunction) x = SomeFunction();
> if ( x ) return !x;

Again:

  if (decltype(auto) x = SomeFunction()) return !x;

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

Received on 2026-01-13 15:55:28