Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-03-31 07:39:28


"David Abrahams" <dave_at_[hidden]> wrote in message
news:uhditw87f.fsf_at_boost-consulting.com...
| "Thorsten Ottosen" <nesotto_at_[hidden]> writes:

| > range_adl_begin()
| > range_adl_end()
| > range_adl_size()
| >
| > Any comments before I commit?
|
| [I hope we've dropped "adl_" from the name by now ;-) ]

yes.

| A scheme like this one has at least one advantage that we should be
| sure to take advantage of: it allows us to reduce the number of
| overloads required by conforming range classes.

| // Note: this partial specialization is important!
| template <class Sequence>
| struct begin_iterator<Sequence const>
| {
| typedef typename sequence::traits<
| Sequence
| >::begin_const_iterator type;
| };

| // Note: no overload for Range const&. This is never
| // called directly, so it always receives an lvalue.
| template <class Range>
| typename begin_iterator<Sequence>::type
| sequence_begin(Range& s)
| {
| return ... // whatever
| }

This is a good observation. You can already do that as

template< class R >
inline typename range_result_iterator<R>::type range_begin( R& r );
                      ^^^^^^^^^^^^^^^^^^^^^^^^

I don't use partial specialization, but rather eval_if< is_const<R>,
const_iterator, iterator>::type, but
I guess that not thaht important.

I will update the docs to reflect this easier way to adopt a new type. And I
will consider
removing half of the actual function implementations.

-Thorsten


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