Is there any interest in Boost.Conversion?

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.Conve... 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)) std::vector<A1,std::allocator<A1> > va6( boost::convert_to<std::vector<A1,std::allocator<A1> > >(pack(vb2, std::allocator<A1>()))); Note that when the Target constructor has some arguments (as is the case for vector with a specific allocator) we pack the Source and the Target arguments in a pack. The first argument is the Source. boost::conversion::pack(vb2, std::allocator<A1>()) The function 'pack' is currently a little bit rudimentary, but is usable already for vector conversions using a specific allocator. Currently accepts only two parameters, I plan to go up to 5 parameters. Any suggestion for better namming 'boost::conversion::pack'. I have no solution for the ambiguity problem of a user getting two different overloads of the same conversion on different namespaces, other than suggesting that convert_to overloadings should be done on the namespace of the Source, for example. Jeffrey does this answer to your attends? I will release the pack function and vector conversion (v.0.5) on the Vault once I will update the documentation. Comments are welcome :) Best, _____________________ Vicente Juan Botet Escribá http://viboes.blogspot.com/

On 5/28/2010 5:23 AM, vicente.botet 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.Conve...
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))
std::vector<A1,std::allocator<A1> > va6( boost::convert_to<std::vector<A1,std::allocator<A1> > >(pack(vb2, std::allocator<A1>())));
Note that when the Target constructor has some arguments (as is the case for vector with a specific allocator) we pack the Source and the Target arguments in a pack. The first argument is the Source.
boost::conversion::pack(vb2, std::allocator<A1>())
The function 'pack' is currently a little bit rudimentary, but is usable already for vector conversions using a specific allocator. Currently accepts only two parameters, I plan to go up to 5 parameters. Any suggestion for better namming 'boost::conversion::pack'.
I have no solution for the ambiguity problem of a user getting two different overloads of the same conversion on different namespaces, other than suggesting that convert_to overloadings should be done on the namespace of the Source, for example.
Jeffrey does this answer to your attends?
I will release the pack function and vector conversion (v.0.5) on the Vault once I will update the documentation.
Comments are welcome :)
Best, _____________________ Vicente Juan Botet Escribá http://viboes.blogspot.com/
I'll have to take a look at this later. Note that in the application where I might've used a Conversion library, I now just use a user-provided function object to define the conversions involved, which works well for my purposes. As far as the ambiguity problem, I've tried using the following framework. Essentially, you want to be able to customize the behavior of convert_to(From&, type_tag<To>) via ADL. What you could do is first call convert_to0 unqualified, with the convention that this would be specialized in From's namespace. The default behavior is then to call convert_to1 unqualified, with the convention that this would be specialized in To's namespace. Perhaps you can rename convert_to0 and convert_to1 to convert_to_from and convert_to_to, or something. This might resolve the ambiguity issues, at least to a sufficient degree... - Jeff

----- Original Message ----- From: "Jeffrey Lee Hellrung, Jr." <jhellrung@ucla.edu> To: <boost@lists.boost.org> Sent: Friday, May 28, 2010 5:08 PM Subject: Re: [boost] Is there any interest in Boost.Conversion? On 5/28/2010 5:23 AM, vicente.botet wrote:
Jeffrey does this answer to your attends?
I will release the pack function and vector conversion (v.0.5) on the Vault once I will update the documentation.
Comments are welcome :)
I'll have to take a look at this later. Note that in the application where I might've used a Conversion library, I now just use a user-provided function object to define the conversions involved, which works well for my purposes. As far as the ambiguity problem, I've tried using the following framework. Essentially, you want to be able to customize the behavior of convert_to(From&, type_tag<To>) via ADL. What you could do is first call convert_to0 unqualified, with the convention that this would be specialized in From's namespace. The default behavior is then to call convert_to1 unqualified, with the convention that this would be specialized in To's namespace. Perhaps you can rename convert_to0 and convert_to1 to convert_to_from and convert_to_to, or something. This might resolve the ambiguity issues, at least to a sufficient degree... - Jeff _______________________________________________ Yeah, this gives priority to one namespace. I will try it? Thanks for the trick, Vicente

On Fri, May 28, 2010 at 5:23 AM, vicente.botet <vicente.botet@wanadoo.fr> 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.Conve...
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)); Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode

----- Original Message ----- From: "Emil Dotchevski" <emil@revergestudios.com> To: <boost@lists.boost.org> 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@wanadoo.fr> 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.Conve...
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

On Fri, May 28, 2010 at 2:55 PM, vicente.botet <vicente.botet@wanadoo.fr> wrote:
----- Original Message ----- From: "Emil Dotchevski" <emil@revergestudios.com> 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 :)
The user can wrap the iterators and inserters in a function, and then it'd be just a function too. That is, if they care; personally I wouldn't bother.
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.
Implicit conversions are something else entirely. The reason why they need to be members is not entirely clear to me, but I'd speculate that it has to do with syntax, not semantics. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode

----- Original Message ----- From: "Emil Dotchevski" <emil@revergestudios.com> To: <boost@lists.boost.org> Sent: Saturday, May 29, 2010 6:16 AM Subject: Re: [boost] Is there any interest in Boost.Conversion? On Fri, May 28, 2010 at 2:55 PM, vicente.botet <vicente.botet@wanadoo.fr> wrote:
----- Original Message ----- From: "Emil Dotchevski" <emil@revergestudios.com> 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 :)
The user can wrap the iterators and inserters in a function, and then it'd be just a function too. That is, if they care; personally I wouldn't bother. _______________________________________________ The idea is to name the function in a uniform way so generic algorithms can use it. Vicente

----- Original Message ----- From: "Emil Dotchevski" <emil@revergestudios.com> To: <boost@lists.boost.org> Sent: Saturday, May 29, 2010 6:16 AM Subject: Re: [boost] Is there any interest in Boost.Conversion? On Fri, May 28, 2010 at 2:55 PM, vicente.botet <vicente.botet@wanadoo.fr> wrote:
----- Original Message ----- From: "Emil Dotchevski" <emil@revergestudios.com>
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.
Implicit conversions are something else entirely. The reason why they need to be members is not entirely clear to me, but I'd speculate that it has to do with syntax, not semantics.
I don't think the syntax could be the problem. We have different syntax for operator+ depending on whether it is used as a member inside a class or as non-member function, but the user uses it in the same way. BTW, there is an old C++ proposal N2200 "OperatorOverloading" http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2200.pdf that propose "Allowing overloading of the cast operators + Allowing global overloading of all operators" If these operator overloads where introduced into the language, we will not need convert_to. The function convert_to tries to replace these explicit and extrinsic conversion operator that are not available now in C++. Best, Vicente

On Fri, May 28, 2010 at 8:23 AM, vicente.botet <vicente.botet@wanadoo.fr> wrote:
Note that when the Target constructor has some arguments (as is the case for vector with a specific allocator) we pack the Source and the Target arguments in a pack. The first argument is the Source.
boost::conversion::pack(vb2, std::allocator<A1>())
The function 'pack' is currently a little bit rudimentary, but is usable already for vector conversions using a specific allocator. Currently accepts only two parameters, I plan to go up to 5 parameters. Any suggestion for better namming 'boost::conversion::pack'.
boost::tuple? std::tuple? ie how does pack differ from tuple? Tony
participants (4)
-
Emil Dotchevski
-
Gottlob Frege
-
Jeffrey Lee Hellrung, Jr.
-
vicente.botet