From e8c9b4a51a1c8f1230b023b0af6a708881ef23d3 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Wed, 3 Sep 2003 18:18:15 +0000 Subject: [PATCH 1/1] implemented operator-> for the iterators --- ginac/ex.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ginac/ex.h b/ginac/ex.h index d3c801e2..1d9fa879 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -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 operator->() const { - return &(operator*()); + return std::auto_ptr(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 operator->() const + { + return std::auto_ptr(new ex(operator*())); + } const_preorder_iterator &operator++() { @@ -609,7 +610,10 @@ public: return r.e.op(r.i); } - // operator->() not implemented + std::auto_ptr operator->() const + { + return std::auto_ptr(new ex(operator*())); + } const_postorder_iterator &operator++() { -- 2.44.0