
11 Jul
2007
11 Jul
'07
1:48 p.m.
On 10/07/07, Marat Khalili <0x8.0p15@rol.ru> 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.
It seems like a std::transform with a type conversion func and into an insert iterator would do the job, or an iterator range constructor from some kind of transform_iterator that I'm sure is in boost somewhere. std::vector<int> vi; v += 1,2,3,4,5; std::vector<std::string> vs; std::transform( vi.begin(), i.end(), std::back_inserter(vs), &boost::lexical_cast<std::string,int> ); HTH, ~ Scott McMurray P.S. We have containers in C++, not collections.