Topic: Standard signature for allocator destructor?


Author: apm35@student.open.ac.uk (apm)
Date: Fri, 17 Sep 2004 16:26:30 GMT
Raw View
My reading of the std is that the signature of a custom allocator
should follow the pattern laid out by the default allocator.

Section 20.1.5 (page 354) says that the std library lays down the
requirements for allocators. The requirements are in table 32 (page
356). However, the table does not specify signatures for the allocator
constructor or destructor. It is reasonable to assume (IMO) that the
signatures should follow the form of the default allocator in section
20.4.1. I cannot find anywhere in the std where it actually says this
though.

This causes a serious problem: if one inherits from a custom allocator
that DOES conform to the default allocator dtor signature then the
derived class must also have a dtor with an empty throw list.
Otherwise a compilation error can result (not all compilers watch out
for this but some definitely do). This issue just caused a compilation
error in some code I am working on. So it is a real problem.

Suppose the derived class had been written by someone else. And that
it could not be changed. Then I would have to change the signature of
my allocator dtor so as NOT to conform to the pattern laid out in
section 20.4.1 to make the compilation error go away. But I feel that
this change makes me violate the std. Except that the std seems to be
a little grey in this area. Can anyone shed any light please? I would
like to tell the author of the derived class that he has to change
because I am conformant and he is not. But its hard to do that when
the std doesnt seem to cover it completely.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]