[squid-dev] [PATCH] Non-zeroing mempools
Alex Rousskov
rousskov at measurement-factory.com
Sun Aug 23 23:55:30 UTC 2015
On 08/23/2015 04:22 PM, Kinkie wrote:
>> Omitting emplace and implementing the others as protected for
>> completeness' sake.
> Why protected?
>
> * Making default constructor protected is the same as keeping it public
> because the class is abstract (nobody can create a StoreMeta object).
>
> * If you want to prohibit copying, use "= delete" for copy constructor
> and assignment operator. Given the class use of raw pointers, deleting
> sounds like a good idea, but I did not study this class usage in detail.
> In general, prohibiting dangerous operations is better than allowing
> them so if "= delete" works well, we should use it.
> With private (on clang)
The default constructor should be _public_. Sorry if my explanation why
protected is essentially the same as public (in this context) made you
think that I recommended to make the default constructor private.
> StoreMeta.cc:100:22: error: call to implicitly-deleted default
> constructor of 'StoreMetaMD5'
> result = new StoreMetaMD5;
> ^
> ../src/StoreMetaMD5.h:16:22: note: default constructor of 'StoreMetaMD5'
> is implicitly deleted because base class 'StoreMeta' has an inaccessible
> default constructor
> class StoreMetaMD5 : public StoreMeta
> ^
That error matches my expectations: Kids cannot access private parent
members, including constructors.
Hope this clarifies,
Alex.
More information about the squid-dev
mailing list