I think it would be great to make boost::any's memory allocation strategy for value holder customizable. It would allow to use not only global new operator, but any other special fast allocators like, for example, Loki::SmallObject.

The changes are minor and would not break existing code.

All it takes is to change class name and:

struct use_default_allocator {};
//class any
template<class A = use_default_allocator> class any_ex
// ...
// class placeholder
class placeholder : public A // derive operators new() and delete()
// ...

typedef any_ex<> any; // for not breaking existing code

And change any_cast functions appropriately.

I've measured performance using Intel VTune. The any_ex<Loki::SmallObject> was about twice as fast as any_ex<> with MS VC++ 7 and Intel C++ 7.

There is sure a possibility to write a faster allocator than Loki::SmallObject.

So, the hardcoded memory allocation strategy makes more harm then good to boost::any. Changes would make boost::any more extensible and reusable.