diff --git a/include/clad/Differentiator/ArrayExpression.h b/include/clad/Differentiator/ArrayExpression.h index 6222eee61..6c84736cc 100644 --- a/include/clad/Differentiator/ArrayExpression.h +++ b/include/clad/Differentiator/ArrayExpression.h @@ -121,51 +121,19 @@ class array_expression { const array_expression&, BinaryDiv, RE>( *this, r); } - // Operator overload for addition. - template - array_expression&, BinaryAdd, - const array_expression&> - operator+(const array_expression& r) const { - return array_expression&, BinaryAdd, - const array_expression&>(*this, r); - } - - // Operator overload for multiplication. - template - array_expression&, BinarySub, - const array_expression&> - operator*(const array_expression& r) const { - return array_expression&, BinaryMul, - const array_expression&>(*this, r); - } +}; - // Operator overload for subtraction. - template - array_expression&, BinarySub, - const array_expression&> - operator-(const array_expression& r) const { - return array_expression&, BinarySub, - const array_expression&>(*this, r); - } +// A class to determine whether a given type is array_expression. +template struct is_array_expr : std::false_type {}; - // Operator overload for division. - template - array_expression&, BinaryDiv, - const array_expression&> - operator/(const array_expression& r) const { - return array_expression&, BinaryDiv, - const array_expression&>(*this, r); - } -}; +template +struct is_array_expr> + : std::true_type {}; // Operator overload for addition, when the right operand is an array_expression // and the left operand is a scalar. template ::value, int>::type = 0> + typename std::enable_if::value, int>::type = 0> array_expression&> operator+(const T& l, const array_expression& r) { @@ -177,7 +145,7 @@ operator+(const T& l, const array_expression& r) { // Operator overload for multiplication, when the right operand is an // array_expression and the left operand is a scalar. template ::value, int>::type = 0> + typename std::enable_if::value, int>::type = 0> array_expression&> operator*(const T& l, const array_expression& r) { @@ -189,7 +157,7 @@ operator*(const T& l, const array_expression& r) { // Operator overload for subtraction, when the right operand is an // array_expression and the left operand is a scalar. template ::value, int>::type = 0> + typename std::enable_if::value, int>::type = 0> array_expression&> operator-(const T& l, const array_expression& r) {