Boost logo

Boost :

Subject: Re: [boost] Is there any interest in Boost.Conversion?
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-05-28 17:55:28


----- Original Message -----
From: "Emil Dotchevski" <emil_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, May 28, 2010 8:36 PM
Subject: Re: [boost] Is there any interest in Boost.Conversion?

On Fri, May 28, 2010 at 5:23 AM, vicente.botet <vicente.botet_at_[hidden]> wrote:
> Hi,
>
> The Boost.Conversion library (Generic explicit conversion between unrelated types) has not revealed too much interest for the Boost community since v0.4 was released on 10/09.
>
> For those that don't know it yet you can get the documentation and download links from
> https://svn.boost.org/trac/boost/wiki/LibrariesUnderConstruction#Boost.Conversion
>
> I have added on the sandbox some pending issues that Jeffrey Hellrung related to conversions that need extra information.
>
> If B1 is covertible to A1 using convert_to, now we can conver vectors of conversible types.
>
> B1 b10, b11, b12, b13;
> std::vector<B1> vb2;
> vb2[0]=b10;
> vb2[1]=b11;
> vb2[2]=b12;
> vb2[3]=b13;
> std::vector<A1> va2(boost::convert_to<std::vector<A1> >(vb2))

What's wrong with

std::vector<A1> va2;
std::transform(vb2.begin(),vb2.end(),std::inserter(va2,va2.end()),bind(convert_to<A1>,_1));

_______________________________________________

Nothing. I find the expression longer, useing of iterators, inserters, binds, a place holder .... While the other uses just a function :)
I think that conversions and assignation are a special case of transformations that merit special attention. Don't you?
Or why we have conversion operators in C++? The question is why these operations need to be defined inside a class in a intrinsic way and not outside in a extrinsic way.

Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk