From: Christian Bauer Date: Wed, 3 Sep 2003 18:18:15 +0000 (+0000) Subject: implemented operator-> for the iterators X-Git-Tag: release_1-2-0~105 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=e8c9b4a51a1c8f1230b023b0af6a708881ef23d3;ds=sidebyside implemented operator-> for the iterators --- 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++() {