Boost logo

Boost :

From: David White (dave_at_[hidden])
Date: 2002-04-28 02:46:29

On Sun, 2002-04-28 at 16:19, hicks wrote:
> To David White
> I did not realize that there would be a seperate allocator for each
> object size.
> Is that right?

Well, originally I had in mind one allocator that would be shared
between arrays. However, the arithmetic needed to make sure that objects
are aligned properly is actually substantial, so I moved to having one
allocator for each object size. I'm not sure if this is the right
decision though, I think doing it either way has its merits.

> I am having some trouble getting var_len_array.hpp and the test package
> to compile under borland.
> I had to elise the line
> #ifndef __BORLANDC__
> template<std::size_t ObjSize>
> detail::stack_allocator_impl<ObjSize> stack_allocator<ObjSize>::instance;
> #endif
> in order to compile up to link.

Well, afaik this is the proper way to define a static member of a class
template, so unless someone can tell me otherwise I'll assume that
Borland is simply doing the wrong thing in this case.

I tried several other ways of implementing the singleton allocator,
including some ways that I am fairly sure would work better on other
compilers, but which exacted a substantial performance hit. E.g. using a
Meyer's Singleton:


static detail::stack_allocator_impl<ObjSize> instance;

(note that this is the declaration in the class, not the definition)


static detail::stack_allocator_impl<ObjSize>& instance() {
    static detail::stack_allocator_impl<ObjSize> theinstance;
    return theinstance;

Then delete the definition I had previously, and change all occurences
of stack_allocator<xxx>::instance to stack_allocator<xxx>::instance().

Unfortunately this performs substantially worse than the original
solution (at least on my system - gcc/Linux).


Boost list run by bdawes at, gregod at, cpdaniel at, john at