NHacker Next
  • new
  • past
  • show
  • ask
  • show
  • jobs
  • submit
C++26: Structured Bindings in Conditions (sandordargo.com)
Panzerschrek 4 hours 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 3 hours 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 4 hours ago [-]
The return value of foo(n), converted to bool, acts as the condition variable…
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
Rendered at 10:27:34 GMT+0000 (Coordinated Universal Time) with Vercel.