NThe Prayer Network
  • new
  • past
  • show
  • ask
  • show
  • jobs
  • submit
C++26: Structured Bindings in Conditions (sandordargo.com)
Panzerschrek 2 days ago [-]
> if (const auto& [is_successful, error_message] = foo(n))

I don't like it. It's hard to reason what exactly serves as condition variable.

daemin 2 days ago [-]
Should probably make it explicit in this case, something like: if (const auto& [is_successful, error_message] = foo(n); is_successful)

In a more normal scenario you'd expect to use std::expected here rather than a custom struct with an operator bool.

addaon 2 days ago [-]
The return value of foo(n), converted to bool, acts as the condition variable…
porise 1 days ago [-]
Yeah I wouldn't like this in a code review. Add one more line of code so I don't have to investigate foo().

That's my fundamental gripe with C++

int i = 0;

function_0(i,...);

...

function_9(i,...);

which one changes i? It's not obvious in a code review due to default mutable references.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
Rendered at 20:14:14 GMT+0000 (Coordinated Universal Time) with Vercel.