[squid-dev] [PATCH] polish Config2 using C++11 features

Alex Rousskov rousskov at measurement-factory.com
Fri Sep 30 16:09:22 UTC 2016


On 09/30/2016 09:38 AM, Amos Jeffries wrote:
> We now seem to have had several patches successfully use members
> declared with default values and/or with the "*this = Foo();" shortcut
> for a reset/clear method.

The *this assignment works for pre-C++11 v3.5 as well. The default
values will not work there so we should be extra careful when
backporting affected code.


> So I think we can start using these to replace old C-style
> initialization and clear() functions.

Agreed. I wonder whether we should be consistent -- if some class data
members cannot use default initialization and some can, should we
initialize _all_ members in the constructor(s)?


> This patch begins by replacing the Config2 use of memset(). I for one am
> constantly mistaking which of the Config objects has memset() applied to
> it at the global level when reconfigure happens. Now we do not need to
> care, each object handles its own clearing one way or another.

+1

Alex.



More information about the squid-dev mailing list