Microsoft Visual Studio Community 2019
Version 16.11.2
Visual Studio.16.Release/16.11.2+31624.102
Installed Version: Community
Visual C++ 2019   00435-60000-00000-AA535
Microsoft Visual C++ 2019
I'm trying to create a simple stack and include simple arithmetic operations. The containing class is templated. I thought that the arithmetic operations of the class template would be applied and allow the arithmetic operations to proceed.
The error messages with the following code are:
Error   C2679   binary '+=': no operator found which takes a right-hand operand of type 'Values' (or there is no acceptable conversion) line 194    
Error   C2679   binary '+=': no operator found which takes a right-hand operand of type 'Values' (or there is no acceptable conversion) line 196    
Error   C2679   binary '+=': no operator found which takes a right-hand operand of type 'Values *' (or there is no acceptable conversion) line195   
---- code ----
# include <stack>
# include <deque>
using namespace std;
class Values {
   long double value[3] = {0.0, 0.0, 0.0};
public:
   Values() {}
   Values(Values& v) { asgn(v); };
   Values(long double value0, long double value1, long double value2) {
      asgn(value0, value1, value2);
   };
   long double& operator[](const int i) { return value[min(2, max(0, i))]; };
   Values& operator+=(Values  value) { return sumt(value);   };
   Values& operator+=(Values* value) { return sumt(*value);  };
   Values& operator+=(long double v) { return sumt(v);       };
   Values& operator-=(Values  value) { return subt(value);  };
   Values& operator-=(Values* value) { return subt(*value); };
   Values& operator-=(long double v) { return subt(v);      };
   Values& operator*=(Values  value) { return mult(value);  };
   Values& operator*=(Values* value) { return mult(*value); };
   Values& operator*=(long double v) { return mult(v);      };
   Values& operator/=(Values  value) { return divt(value);  };
   Values& operator/=(Values* value) { return divt(*value); };
   Values& operator/=(long double v) { return divt(v);      };
   Values& operator=( Values  value) { return asgn(value);  };
   Values& operator=( Values* value) { return asgn(*value); };
   Values& operator=( long double v) { return asgn(v);      };
   Values& operator+( Values  value) { return add(value);   };
   Values& operator+( long double v) { return add(v);       };
   Values& operator-( Values  value) { return sub(value);   };
   Values& operator-( long double v) { return sub(v);       };
   Values& operator*( Values  value) { return mul(value);   };
   Values& operator*( long double v) { return mul(v);       };
   Values& operator/( Values  value) { return div(value);   };
   Values& operator/( long double v) { return div(v);       };
   Values& asgn(Values& value) {
      this->value[0] = value[0];
      this->value[1] = value[1];
      this->value[2] = value[2];
      return *this;
   };
   Values& asgn(long double v) {
      value[0] = value[1] = value[2] = v;
      return *this;
   };
   Values& asgn(const long double value0, const long double value1, const long double value2) {
      value[0] = value0;
      value[1] = value1;
      value[2] = value2;
      return *this;
   };
   Values& sumt(Values& value) {
      this->value[0] += value[0];
      this->value[1] += value[1];
      this->value[2] += value[2];
      return *this;
   };
   Values& sumt(long double v) {
      this->value[0] += v;
      this->value[1] += v;
      this->value[2] += v;
      return *this;
   };
   Values& subt(Values& value) {
      this->value[0] -= value[0];
      this->value[1] -= value[1];
      this->value[2] -= value[2];
      return *this;
   };
   Values& subt(long double v) {
      this->value[0] -= v;
      this->value[1] -= v;
      this->value[2] -= v;
      return *this;
   };
   Values& mult(Values& value) {
      this->value[0] *= value[0];
      this->value[1] *= value[1];
      this->value[2] *= value[2];
      return *this;
   };
   Values& mult(long double v) {
      this->value[0] *= v;
      this->value[1] *= v;
      this->value[2] *= v;
      return *this;
   };
   Values& divt(Values& value) {
      this->value[0] /= value[0];
      this->value[1] /= value[1];
      this->value[2] /= value[2];
      return *this;
   };
   Values& divt(long double v) {
      this->value[0] /= v;
      this->value[1] /= v;
      this->value[2] /= v;
      return *this;
   };
   Values& add(Values& value) {
      Values v;
      v[0] = this->value[0] + value[0];
      v[1] = this->value[1] + value[1];
      v[2] = this->value[2] + value[2];
      return v;
   };
   Values& add(long double v) {
      Values value;
      value[0] = this->value[0] + v;
      value[1] = this->value[1] + v;
      value[2] = this->value[2] + v;
      return value;
   };
   Values& sub(Values& value) {
      Values v;
      v[0] = this->value[0] - value[0];
      v[1] = this->value[1] - value[1];
      v[2] = this->value[2] - value[2];
      return v;
   };
   Values& sub(long double v) {
      Values value;
      value[0] = this->value[0] - v;
      value[1] = this->value[1] - v;
      value[2] = this->value[2] - v;
      return value;
   };
   Values& mul(Values& value) {
      Values v;
      v[0] = this->value[0] * value[0];
      v[1] = this->value[1] * value[1];
      v[2] = this->value[2] * value[2];
      return v;
   };
   Values& mul(long double v) {
      Values value;
      value[0] = this->value[0] * v;
      value[1] = this->value[1] * v;
      value[2] = this->value[2] * v;
      return value;
   };
   Values& div(Values& value) {
      Values v;
      v[0] = this->value[0] / value[0];
      v[1] = this->value[1] / value[1];
      v[2] = this->value[2] / value[2];
      return v;
   };
   Values& div(long double v) {
      Values value;
      value[0] = this->value[0] / v;
      value[1] = this->value[1] / v;
      value[2] = this->value[2] / v;
      return value;
   };
}; // class Values
template <class T>
class Stack {
   stack<T> s;
public:
   Stack() {}
   Stack(const Stack& value) { for (T v : value) s.push(v); }
   ~Stack() { }
   T&     push(T item)        { s.push(item); return item; }
   T      pop()               { T v = s.top(); s.pop(); return v; }
   T&     top()               { return s.top();   }
   bool   empty()             { return s.empty(); }
   size_t size() const        { return s.size();  }
   T& operator+=(T& other)    {s.top() += other; return s.top(); }
   T& operator-=(T& other)    {s.top() -= other; return s.top(); }
   T& operator*=(T& other)    {s.top() *= other; return s.top(); }
   T& operator/=(T& other)    {s.top() /= other; return s.top(); }
   T& operator+ (T& other)    { return (s.top() + other); }
   T& operator- (T& other)    { return (s.top() - other); }
   T& operator* (T& other)    { return (s.top() * other); }
   T& operator/ (T& other)    { return (s.top() / other); }
   T& add()                   { T item = s.top(); s.pop(); return (s.top() += item); }
   T& sub()                   { T item = s.top(); s.pop(); return (s.top() -= item); }
   T& mul()                   { T item = s.top(); s.pop(); return (s.top() *= item); }
   T& div()                   { T item = s.top(); s.pop(); return (s.top() /= item); }
};
int main(int argc, char** argv) {
   Stack<Values> s;
   Values  v = Values(1.0, 2.0, 3.0);
   Values* z = new Values(1.0, 2.0, 3.0);
   s.push(v);
   Values x = s.top();
   s += Values(1.0, 2.0, 3.0);
   s += new Values(1.0, 2.0, 3.0);
   s.top() += Values(1.0, 2.0, 3.0);
   s +=  v;
   s += *z;
   s.top() += new Values(1.0, 2.0, 3.0);
   x += new Values(1.0, 2.0, 3.0);
   x += 2.0;
   return 0;
}
 
    