Back to News
Advertisement
Advertisement

⚡ Community Insights

Discussion Sentiment

50% Positive

Analyzed from 51 words in the discussion.

Trending Topics

#foo#const#auto#amp#condition#variable#bool#don#hard#reason

Discussion (3 Comments)Read Original on HackerNews

Panzerschrek•about 8 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•about 8 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•about 8 hours ago
The return value of foo(n), converted to bool, acts as the condition variable…