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