Boost logo

Boost :

Subject: Re: [boost] [conversion] review
From: Gordon Woodhull (gordon_at_[hidden])
Date: 2011-08-31 20:45:03


On Aug 31, 2011, at 5:11 PM, Emil Dotchevski wrote:
> On Wed, Aug 31, 2011 at 1:13 PM, Gordon Woodhull <gordon_at_[hidden]> wrote:
>>
>> On Aug 31, 2011, at 3:01 PM, Emil Dotchevski wrote:
>>> I do agree however that the call syntax should not rely on <>. One
>>> reason is that it turns off ADL. Another reason is that sometimes an
>>> implicit conversion to match an existing non-template overload is
>>> preferable to instantiating a template.
>>
>> The function overload customization point in Conversion uses a dummy parameter and no <>. convert_to<> is a just a more pleasant wrapper over that. So I think these language features are still available.
>
> What makes it more pleasant? Is it more convenient? In what use cases?

We are talking about a library that emulates overloading static_cast. The wrapper makes it look somewhat like static_cast<>(), whereas if you directly had to use the customization point it would be a mess:

conversion::convert_to<Target>(source);
versus
explicit_convert_to(source, conversion::type_tag<Target>())

In other words, the ugliness is confined to the definition of conversions and doesn't spill over into their use. But the conversion definitions do get to benefit from ADL... actually I don't see how a conversion library could benefit from implicit conversions of the target type, but I might be missing something.

Cheers,
Gordon


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