On Sun, Sep 14, 2008 at 10:07:51PM +0200, Abdelrazak Younes wrote: > Vincent van Ravesteijn wrote: >> Jean-Marc Lasgouttes wrote: >>> >>> JMarc >>> >> >> Hi JMarc, >> >> I have processed your comments. I also removed als Change::UNCHANGED >> and friends from the code. I had to work with objects after all, due >> to the Change::color function. If you like it, we might change it in >> other parts of the code. >> >> One question: >> >> I have written : >> >> Change & change_running = Change() ; > > change_running points to nothing valid.
Hm... not really. The problem is that Change() is an rvalue that can't be bound to an non-const reference (says the Standard, not MSVC...) If it were written Change const & change_running = Change(); it would be valid, and the lifetime of the temporary Change() would be extended to the one of the reference it is bound to (i.e. change_running, which lives to the end of the block). However, I doubt such a thing is very useful in any case. You get a non-mutable default-constructed object... > >> Change const & change = par_.lookupChange(pos); >> .... >> change_running = change; >> >> to copy the members of the object. Is this ok ? Why not Change change_running = change; ?