From: Jack on
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

"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

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
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