| kassert
    1.0.0
    Assertion library for KaMPIng | 
Expression decomposition. More...


Go to the source code of this file.
| Classes | |
| struct | kassert::internal::AlwaysFalse< T > | 
| Type trait that is always false, to implement static_asserts that always fail, thus preventing a template function from being instanciated. Used to forbid calling the overloads of && and ||.  More... | |
| class | kassert::internal::Expression | 
| Interface for decomposed unary and binary expressions.  More... | |
| class | kassert::internal::BinaryExpression< LhsT, RhsT > | 
| A decomposed binary expression.  More... | |
| class | kassert::internal::UnaryExpression< LhsT > | 
| Decomposed unary expression.  More... | |
| class | kassert::internal::LhsExpression< LhsT > | 
| The left hand size of a decomposed expression. This can either be turned into a BinaryExprif an operand or relation follows, or into aUnaryExprotherwise.  More... | |
| struct | kassert::internal::Decomposer | 
| Decomposes an expression (see group description).  More... | |
| Functions | |
| bool | kassert::internal::finalize_expr (bool const result) | 
| If an expression cannot be decomposed (due to && or ||, to preserve short-circuit evaluation), simply return the result of the assertion. | |
| template<typename ExprT > | |
| decltype(auto) | kassert::internal::finalize_expr (ExprT &&expr) | 
| Transforms LhsExpressionintoUnaryExpression, does nothing to aExpression(see group description). | |
Expression decomposition.
Failed assertions try to expand the expression similar to what Catch2 does. This is achieved by the following process:
In a call
 KASSERT() also prints the values of rhs and lhs. However, this expression expansion is limited and only works for expressions that do not contain parentheses, but are implicitly left-associative. This is due to its implementation: 
is replaced by
which is interpreted by the compiler as
where the first <= relation is overloaded to return a proxy object which in turn overloads other operators. If the expression is not implicitly left-associative or contains parentheses, this does not work:
is replaced by (with implicit parentheses)
 Thus, the left hand side of && can only be expanded to the result of rhs2 == lhs2. This limitation only affects the error message, not the interpretation of the expression itself. 
If an expression cannot be decomposed (due to && or ||, to preserve short-circuit evaluation), simply return the result of the assertion.
| result | Result of the assertion. | 
| decltype(auto) kassert::internal::finalize_expr | ( | ExprT && | expr | ) | 
Transforms LhsExpression into UnaryExpression, does nothing to a Expression (see group description). 
| ExprT | Type of the expression, either LhsExpressionor aBinaryExpression. | 
| expr | The expression. | 
Expression.