Boost logo

Boost :

From: Cédric Venet (cedric.venet_at_[hidden])
Date: 2007-07-11 10:16:40

Quoting Ulrich Eckhardt <doomster_at_[hidden]>:

> 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.

Cédric Venet

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