|
Boost Users : |
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2006-04-27 12:45:05
Kobi Cohen-Arazi wrote:
> Will not work !
> Why adding the & hurts?
> Kobi.
Because you attempt to bind a non-const reference to a temporary object
(the return value of get(). The compiler refuses to do that.
The compiler doesn't catch another possibly problematic situation,
though, and that's replace's return by reference. You're returning a
reference to a function parameter, and that's generally not a good idea.
On the other hand, the removeConst function does absolutely nothing in
your program except create yet another copy of the string. get() already
returns a copy. The function is const, but its return value is not a
const reference.
Sebastian Redl
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net