Vladimir Prus wrote: > Aha, that's what I was trying to say, but not very clearly. Yes, *this* > will work. But... it means that if you do > > any<> a1; > any<fast_allocator> a2 = a1; > Then value stored in a2 will be allocated using a1's allocator, not a2's. > Once any is created with a specific allocator, all copies will use the > same allocator, which is doubtful behaviour. In the example above, the > "fast_allocator" parameter has no effect at all. > > Even if this behavior is desirable, you don't need to add template > parameter to 'any'. I agree, there is no need for the template parameter for any.
> 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? 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>? -- Alexander Nasonov Remove minus and all between minus and at from my e-mail for timely response _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost