If condition - #46
Conversation
…c across core expression templates
…xpression and fix formatting
There was a problem hiding this comment.
Code Review
This pull request introduces the if_then deferred expression and a homogenized_type trait to handle mixed return types using std::variant. It also refactors several expressions to use named members and adds Deferred concept constraints. Feedback highlights regressions in visit methods that break recursive traversal, suggests adding non-const operator() overloads for stateful callables, and recommends using std::decay_t for result types. Additionally, the reviewer suggests adopting the new homogenized_type_t trait in switch_expression for better type safety.
| constexpr explicit default_expression(T&& t) : m_expression(std::forward<T>(t)) | ||
| { } | ||
|
|
||
| [[nodiscard]] constexpr decltype(auto) operator()() const |
There was a problem hiding this comment.
The default_expression class is missing a non-const operator(). This prevents the use of mutable lambdas or other stateful callables as the default case in a switch_ expression.
[[nodiscard]] constexpr decltype(auto) operator()()
{
return evaluate(m_expression);
}
[[nodiscard]] constexpr decltype(auto) operator()() const| } | ||
|
|
||
| /// @brief Returns the result of the body expression. | ||
| [[nodiscard]] constexpr decltype(auto) operator()() const |
There was a problem hiding this comment.
The case_expression class is missing a non-const operator(). This prevents the use of mutable lambdas as the body of a case in a switch_ expression.
/// @brief Returns the result of the body expression.
[[nodiscard]] constexpr decltype(auto) operator()()
{
return evaluate(m_body);
}
/// @brief Returns the result of the body expression.
[[nodiscard]] constexpr decltype(auto) operator()() const
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
@gemini-code-assist please review |
There was a problem hiding this comment.
Code Review
This pull request refactors deferred conditional expressions to support chaining with else_if and else_, and introduces a new homogenized_type trait to support heterogeneous return types via std::variant. It also refactors switch_expression and while_expression to store subexpressions directly instead of using tuples. The reviewer feedback highlights potential use-after-move bugs in switch_expression::choose_case due to improper forwarding, and notes that several visit methods across conditional_expression, switch_expression, and while_expression call the visitor directly on subexpressions instead of recursively propagating the visitation via .visit().
No description provided.