|
Boost Users : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-03-04 09:35:21
David Abrahams wrote:
> "Peter Dimov" <pdimov_at_[hidden]> writes:
>
>> David Abrahams wrote:
>>
>>> ADL might not be the best customization solution.
>>
>> You keep saying that, but I keep disagreeing. ADL is the best
>> customization solution. Not flawless, just better than any of the
>> alternatives.
>
> I guess I haven't seen enough be definitively convinced one way or the
> other. I have heard stories from people who switch to dispatching via
> specialization and report how much better things get. Furthermore,
> Daveed Vandevoorde has convinced me that it is far easier to reason
> about. The rules for matching partial specializations are trivial
> compared to the mess you have to consider when there is overloading.
> The inconvenience of specialization is ugly, but it seems like a
> one-time cost that may be justified for what it buys us.
That's the thing. It doesn't actually buy us anything. It only claims to
avoid potential problems.
* Uglier syntax for defining a specialization.
* Coupling; you need to include a primary template.
* Does not allow a base-specific version to be picked up automatically for
derived classes.
* Does not allow non-exact matches.
* If four libraries need the same operation, you need to specialize four
primary templates.
In practice people tend to respect de-facto standards; a + b is an addition,
and swap(a, b) swaps a and b. The main fight is over who gets to keep the
primary template. But this is not really a problem with ADL customization
points, because in their purest form, there is no primary template. The
primary template is usually a compatibility workaround for types that do not
support the ADL interface yet.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net