> 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.
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.
The return value of foo(n), converted to bool, acts as the condition variable…
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.