Topic: prefix increment/decrement


Author: Hyman Rosen <hymie@prolifics.com>
Date: 2000/02/01
Raw View
Rene van Oostrum <rene@cs.ust.hk> writes:
> According to 5.3.2, the value returned by prefix ++ and prefix --
> should be an lvalue. What is the reason for this requirement?

void f(int &n);
int main(int c, char **v) { f(++c); }


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Rene van Oostrum <rene@cs.ust.hk>
Date: 2000/02/02
Raw View
Hi,

According to 5.3.2, the value returned by prefix ++ and prefix --
should be an lvalue. What is the reason for this requirement?

I tried to come up with some simple code example that would break if
prefix ++ and -- were to return an rvalue instead, such as

  int i=0;
  ++++++i;

but I don't really see the advantage of being able to do that.

Thanks,
Rene

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]