This is the mail archive of the
mailing list for the GDB project.
Re: [RFA 02/22] Use RAII to save and restore scalars
On 09/30/2016 04:17 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <firstname.lastname@example.org> writes:
> Pedro> scoped_restore scope = make_scoped_restore (&some_global);
> I made this change. One minor oddity is that the 2-argument form of
> make_scoped_restore required a copy constructor in the
> scoped_restore_tmpl subclass. I think that's harmless though.
Yeah. We just need to make sure that if a copy constructor does run,
the code behaves as if it hadn't. My earlier comment on that
not mattering may have been incorrect - if the copied-from scoped_restore
is destructed before the make_scoped_restore function returns, then the
global will revert back to the original value too soon. Guess we could
have the copy constructor actually move instead of copy, setting the
copied-from's pointer member to NULL, and then have the
destructor do nothing if the pointer is NULL.