Getting a pointer to an element in a list?
Hi all A hopefully pretty simple question about lists in GiNaC. I have a little fragment of code like this: class SymbolicSystem{ private: GiNaC::lst F; public: const ex * getExpressionPtr(const unsigned &i) const{ *return* &(F[i]); } } Is there something about the implementation of the operator[] in GiNaC::list that stops me from being able to do this? GCC gives me a warning, like this: warning: taking address of temporary This might be an elementary C++ mistake, but just in case, I thought I'd ask. Cheers JP
Hi! On Wed, Aug 17, 2005 at 01:25:16AM +1000, John Pye wrote:
const ex * getExpressionPtr(const unsigned &i) const{ *return* &(F[i]); }
Hm, why do you want to do this? An 'ex' is already a pointer to something, so I don't see much advantage over ex getExpression(unsigned i) const { return F[i]; } Bye, Christian -- / Physics is an algorithm \/ http://www.uni-mainz.de/~bauec002/
I want to update the expression from outisde the class, ie something like ex &x = myobject->getExpression(17); x = x.subs(y==5); How would you suggest I did that? I think that a copy constructor is getting called somewhere but I haven't worked out where yet. Cheers JP Christian Bauer wrote:
Hi!
On Wed, Aug 17, 2005 at 01:25:16AM +1000, John Pye wrote:
const ex * getExpressionPtr(const unsigned &i) const{ *return* &(F[i]); }
Hm, why do you want to do this? An 'ex' is already a pointer to something, so I don't see much advantage over
ex getExpression(unsigned i) const { return F[i]; }
Bye, Christian
Hi! On Wed, Aug 17, 2005 at 10:26:24AM +1000, John Pye wrote:
ex &x = myobject->getExpression(17); x = x.subs(y==5);
How would you suggest I did that?
I suggest using a vector<ex> or a list<ex> instead of a GiNaC lst. Bye, Christian -- / Physics is an algorithm \/ http://www.uni-mainz.de/~bauec002/
participants (2)
-
Christian Bauer
-
John Pye