Gregory Colvin wrote: > On Friday, Aug 29, 2003, at 18:05 America/Denver, David Abrahams > wrote: >> Gregory Colvin <[EMAIL PROTECTED]> writes: >> >>> * use the standard parameterization mechanisms (Allocator) when >>> choosing to parameterize >> >> I'm not sure about this one. std::allocator are a mess, and almost >> everyone knows it. They were designed for containers, and they only >> barely work there, IMO. > > IMO they work just fine, and are not so messy as "everyone" thinks. > The only real ugliness is rebind, but without template typedefs there > isn't much choice. And the only really missing functionality is > reallocation, but one can usually do without that. They can be > difficult to implement well, but I think that is separate issue.
They work, but they arguably aren't well designed. Containers manage memory in different ways. vector<T> allocates, reallocates, and deallocates contiguous blocks of T elements, and it can put a "how much did I just allocate" feature and a "how big is this allocation" feature to good use. Node-based containers allocate single nodes, but not of value_type. Deque allocates fixed size pages (and some additional housekeeping data). I'm not sure that lumping these together in a single Allocator concept has any benefits. The stateful allocator problem is a thorny issue too, since to allow stateful allocators, one needs to specify whether the stored allocator is part of the logical state of the object. IE vector<T, A> v1(a1); vector<T, A> v2(a2); v1 = v2; // which allocator does v1 hold now? Extending this already overstretched concept to function<> is a bad idea IMHO. function<> has its own memory management pattern that does not even resemble a container. In particular function<void(), A> f(a); is not required since f never allocates except when passed an object. function<void(), A> f(x, a); can be made to work without the A template parameter since the constructor is already a template, and x and a can be treated as a whole: function<void()> f(x, a); // allocate pair<X, A> with a, copy x and a into it. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost