Boost logo

Boost :

From: Alexander Nasonov (alnsn-mycop_at_[hidden])
Date: 2003-03-25 10:53:21

Alexander Nasonov wrote:

> Vladimir Prus wrote:
>> You can add template parameter to 'holder' only,
>> and another constructor, which allows to specify allocator.
> But then you can't make static_cast to holder<KnownType, UnknownAllocator>
> inside any_cast<KnownType>(a); May be wrap allocator specific stuff into
> separate interface?

You can if you add one more level of inheritance:

template<class T, class Allocator>
class holder_with_allocator
    : public holder<T> // make static_cast to it
    // ...

> There are two allocator types: (a) type specific ones like
> std::allocator<int> and (b) catch-all allocators.
> Option (a) is probably better when you know the type:
> any<> a(1); // a uses new/delete
> any<> b(2, fast_allocator<int>());
> I don't know whether to leave the original allocator or replace it with
> another one while making a copy:
> any<> c(a); // c uses new/delete
> any<> d(b); // d uses fast_allocator<int>?

I forgot that we're allocating a memory for holder<T> not for type T. But
there is a solution called rebind. So, I really don't know what to choose.

Alexander Nasonov
Remove minus and all between minus and at from my e-mail for timely response

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