|
From: Jack on 8 Apr 2006 00:10 Hi all, if an object is pointed by a iterator, when we take the dereference of this iterator. it should return the lvalue instead of the rvalue. So if p is a mutable iterator, value type is T then *p should return T& not T. Can somebody explain this rule? Thanks Jack
From: Jack on 8 Apr 2006 00:23 "Jack" <jl(a)knight.com> ???g??l??s?D:eMaadJsWGHA.3760(a)TK2MSFTNGP02.phx.gbl... > Hi all, > if an object is pointed by a iterator, when we take the dereference of > this iterator. it should return the lvalue instead of the rvalue. So if p > is a mutable iterator, value type is T then *p should return T& not T. Can > somebody explain this rule? In what circumstances shall we refer it as a lvalue or rvalue? Can anyone raise an example? Say *p = *a; if p and a are T we should return T& to p??? I'm very confusd, pls help Thanks Jack > Thanks > Jack >
From: Sandeep on 9 Apr 2006 23:34 Jack wrote: > > Hi all, > > if an object is pointed by a iterator, when we take the dereference of > > this iterator. it should return the lvalue instead of the rvalue. So if p > > is a mutable iterator, value type is T then *p should return T& not T. Can > > somebody explain this rule? > > In what circumstances shall we refer it as a lvalue or rvalue? Can anyone > raise an example? > Say *p = *a; > if p and a are T > we should return T& to p??? I'm very confusd, pls help Can you give an example and your code fragment to indicate your confusion ?
From: Tom Widmer [VC++ MVP] on 11 Apr 2006 05:22 Jack wrote: > "Jack" <jl(a)knight.com> ???g??l??s?D:eMaadJsWGHA.3760(a)TK2MSFTNGP02.phx.gbl... > >>Hi all, >>if an object is pointed by a iterator, when we take the dereference of >>this iterator. it should return the lvalue instead of the rvalue. So if p >>is a mutable iterator, value type is T then *p should return T& not T. Can >>somebody explain this rule? > > > In what circumstances shall we refer it as a lvalue or rvalue? Can anyone > raise an example? > Say *p = *a; > if p and a are T > we should return T& to p??? I'm very confusd, pls help lvalues are references and variables - basically anything you can take the address of (with &). rvalues are literals and temporaries. If an iterator operator* returned a T rather than a T&, it would return a copy of the object it pointed to, not the object itself. Tom
|
Pages: 1 Prev: compare '-1.#IND' with 1.#INF doubles ? Next: Question about return by reference? |