From 20a11fb5ecac91e723866e03fead9e17c311c344 Mon Sep 17 00:00:00 2001 From: Alvin Zhang <41vin2h4n9@gmail.com> Date: Sun, 1 Dec 2024 10:08:23 -0800 Subject: [PATCH] feat: prevent expressions from being copied --- include/suboptimal/autodiff/Expression.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/suboptimal/autodiff/Expression.h b/include/suboptimal/autodiff/Expression.h index 862e3a8..a3bc557 100644 --- a/include/suboptimal/autodiff/Expression.h +++ b/include/suboptimal/autodiff/Expression.h @@ -61,6 +61,16 @@ struct Expression { AdjointValueFunc rhs_adjoint_value_func, AdjointExprFunc lhs_adjoint_expr_func, AdjointExprFunc rhs_adjoint_expr_func, ExpressionPtr lhs, ExpressionPtr rhs); + Expression(const Expression& other) = delete; + + Expression(Expression&& other) = default; + + Expression& operator=(const Expression& other) = delete; + + Expression& operator=(Expression&& other) = default; + + ~Expression() = default; + /** * Checks if the value of this expression is independent of any other expressions */