Boost logo

Boost :

Subject: Re: [boost] [system] virtual ~error_category
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2018-02-12 20:09:59


>> It also occurs to me now that Charley mentioned to me once that some
>> people instantiate custom categories carrying payload and hand them
>> out one per error_code instance. It's a way of attaching payload to
>> error_code. That use case definitely requires a virtual destructor to
>> work right.
>
> ~error_code does not destroy the category, so the virtuality of the
> destructor makes no difference. The category will leak in either case.

Not if the error code's destructor deletes its category.

> This is also not quite conforming for another reason; the category is
> supposed to be a singleton and two instances should compare equal only
> when they are the same object (per the standard).

People wrote code assuming the category destructor is virtual. It is
right now both in Boost.System and the STL.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk