
On 7/11/07, Cédric Venet <cedric.venet@student.ecp.fr> wrote:
Quoting Ulrich Eckhardt <doomster@knuut.de>:
On Wednesday 11 July 2007 05:55:59 Marat Khalili wrote:
Are there any standard means to clone collection class while changing only element type? Like receiving some_collection<int> as a template parameter and creating some_collection<string> without knowing what exactly some_collection is.
Looks like a case for std::transform(), or?
I think he wants to transform only the type (at compile time). A facility like rebind for the stl allocator.
Somthing like this but specialised for all the stl container:
template<class T,class D> struct rebind; template<class T,class D> struct rebind< std::vector<T>, D > { typedef std::vector<D> type; }; ... typedef rebind< some_collection<int>, string > some_collection_string;
I don't know an existing implementation, and I don't have immediat use of this, but it could be useful.
You can take a look at Boost.ContainerAdaptor, an internal library of Boost.Bimap. There are no docs yet... I will write them soon. Best regards Matias