From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-07-18 14:46:43
I'd like to propose a variation of the 'any' class that addresses the
any r = v ;
return v ;
// The entire vector is copied here.
any r = foo();
Currently, 'any' has a copy-on-copy policy; that is, each time an 'any'
instance is copied, the value it holds is copied too.
This policy is appropriate for small objects, but it is very inefficient if
the values held are big.
I've written two variant classes (see
of which is pretty much the same as 'any'.
The other class has a share-on-copy policy, just like a read-only
std::string; that is, the value is held in a reference counted dynamically
According to my user reports, both variations are equally useful in their
Using boost::shared_ptr it is trivial to implement this 'any' variation.
I attached 'any2.hpp' which is the implementation of this variation.
I named it any2 provisionally, since I can't think of a proper name yet.
Let me know what do you think.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk