implemented operator-> for the iterators
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 3 Sep 2003 18:18:15 +0000 (18:18 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 3 Sep 2003 18:18:15 +0000 (18:18 +0000)
ginac/ex.h

index d3c801e2a1839fd9e8995deccdff45614ae76a1a..1d9fa8794c9b70012d66765755ff1d946478359a 100644 (file)
@@ -396,14 +396,12 @@ public:
                return e.op(i);
        }
 
-#if 0
-       // How do we make this work in the context of the "reference to
-       // temporary" problem? Return an auto_ptr?
-       pointer operator->() const
+       // This should return an ex*, but that would be a pointer to a
+       // temporary value
+       std::auto_ptr<ex> operator->() const
        {
-               return &(operator*());
+               return std::auto_ptr<ex>(new ex(operator*()));
        }
-#endif
 
        ex operator[](difference_type n) const
        {
@@ -544,7 +542,10 @@ public:
                return r.e.op(r.i);
        }
 
-       // operator->() not implemented (see above)
+       std::auto_ptr<ex> operator->() const
+       {
+               return std::auto_ptr<ex>(new ex(operator*()));
+       }
 
        const_preorder_iterator &operator++()
        {
@@ -609,7 +610,10 @@ public:
                return r.e.op(r.i);
        }
 
-       // operator->() not implemented
+       std::auto_ptr<ex> operator->() const
+       {
+               return std::auto_ptr<ex>(new ex(operator*()));
+       }
 
        const_postorder_iterator &operator++()
        {