|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-03-25 03:25:13
Thomas Witt <witt_at_[hidden]> writes:
>> Yes, the whole area of dispatching and customization of generic
>> functions is nasty in C++. I've known it's problematic for a long
>> time, but had a hard time expressing how bad the problem is in a way
>> that would communicate to someone who doesn't do heavy generic
>> programming day in and day out.
>
> I agree that something needs to be done. I just really want to be
> convinced that the proposed changes to boost::begin are the right solution
Without going into the description of the language problems too
deeply, here's a prototype of what Doug and I came up with. So far it
only compiles for me with g++.
Things to notice:
- ADL is limited to *one* name, lookup_implementation()
- ADL is decoupled from the actual types being passed to algorithms
via their category tags
- You can write generalized lookup_implementation() functions like the
one shown, that choose some rules by which to dispatch all
algorithms
- You can write specific lookup_implementation functions to set
different rules for particular algorithms.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk