12 Feb
2018
12 Feb
'18
8:05 p.m.
Niall Douglas wrote:
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. 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).