Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 2000-09-17 08:31:17


John Maddock wrote:

>... Should classes that allocate memory
>always have an allocator parameter, or should that be restricted to
>containers and container-like classes?

Seems like the usual software engineering trade-off: if the benefit is
greater than the cost, use an allocator, otherwise don't.

The benefit of an allocator (improved speed and/or memory control) applies
only when memory allocation is a significant factor in the class's
performance, and the class is performance critical in terms of
applications.

The cost of an allocator (increased interface complexity, code size, etc.)
is always present.

So does class match_results benefit much from having an Allocator template
argument? It doesn't sound like it is worth the cost, but you are in the
best position to judge that.

Also consider that if the interface starts out with an allocator, it is
very hard to remove it. But if it starts out with no allocator, it doesn't
break existing code to add one later.

--Beman


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