Date: Thu, 15 Jan 2026 09:20:34 +0000
On Thu, Jan 15, 2026 at 8:59 AM Ville Voutilainen wrote:
>
> On Thu, 15 Jan 2026 at 10:52, Frederick Virchanza Gotham via
> Std-Proposals <std-proposals_at_[hidden]> wrote:
> > because the following fails to compile:
> >
> > struct C {
> > operator bool(void) const & = delete;
>
> ..as if someone writes code like that, or in any significant numbers.
>
> The idea continues to have insufficient merit, and isn't an
> improvement over what we already have.
It's funny, I feel as though the argument you and Thiago are making
against my idea, is actually an argument in favour of my idea.
Essentially what we are trying to do is mimic the behaviour of
"return CalleeFunction();".
But the complication is that we only want to return from the enclosing
function if the callee's return value becomes true when converted to
bool. So our first attempt is:
if ( auto x = CalleeFunction() ) return x;
In this thread I have demonstrated how mimicking the behaviour of
"return CalleeFunction();" is actually a lot more complicated, as we
need to do:
if ( decltype(auto) x = CalleeFunction();
static_cast<decltype(x)>(x) ) return static_cast<decltype(x)>(x);
This really shows that it's much better to leave it up to the compiler
rather than rely on the programmer to do it right. And here's how you
ask the compiler to do it right:
return if CalleeFunction();
So thank you Thiago and Ville for supporting my idea with your
argument in favour of it.
>
> On Thu, 15 Jan 2026 at 10:52, Frederick Virchanza Gotham via
> Std-Proposals <std-proposals_at_[hidden]> wrote:
> > because the following fails to compile:
> >
> > struct C {
> > operator bool(void) const & = delete;
>
> ..as if someone writes code like that, or in any significant numbers.
>
> The idea continues to have insufficient merit, and isn't an
> improvement over what we already have.
It's funny, I feel as though the argument you and Thiago are making
against my idea, is actually an argument in favour of my idea.
Essentially what we are trying to do is mimic the behaviour of
"return CalleeFunction();".
But the complication is that we only want to return from the enclosing
function if the callee's return value becomes true when converted to
bool. So our first attempt is:
if ( auto x = CalleeFunction() ) return x;
In this thread I have demonstrated how mimicking the behaviour of
"return CalleeFunction();" is actually a lot more complicated, as we
need to do:
if ( decltype(auto) x = CalleeFunction();
static_cast<decltype(x)>(x) ) return static_cast<decltype(x)>(x);
This really shows that it's much better to leave it up to the compiler
rather than rely on the programmer to do it right. And here's how you
ask the compiler to do it right:
return if CalleeFunction();
So thank you Thiago and Ville for supporting my idea with your
argument in favour of it.
Received on 2026-01-15 09:19:32
