Boost logo

Boost :

From: helmut.zeisel_at_[hidden]
Date: 2001-07-26 11:10:12


--- In boost_at_y..., Jeremy Siek <jsiek_at_r...> wrote:
> On Thu, 26 Jul 2001, Fernando Cacciola wrote:
> > (*) Now consider how would this look like if the range is
encapsulated in a
> > single class.
> >
> > template <class Range>
> > void sort_heap (Range range)
> > {
> > Range::iterator first = range.begin() ;
> > Range::iterator last = range.end();
> > while (last - first > 1)
> > pop_heap( Range(first, last--) );
> > }
>
> I thought we were talking about providing a wrapper to the
iterator-pair
> algorithms, not reimplementing the algorithms in terms of ranges.

This is what I meant.

>
> BTW, there's one problem with the above. To efficiently pass in a
> container we need pass-by-reference,

espescially if we want to modify the container...

> but this will cause a problem
if one
> wants to call this with make_range().
>
> sort_heap(make_range(first, last)); // error, binding temporary to a
> // reference
>

I tested using VC++ :-(

Do you have any idea how to solve this problem?
Passing by const reference and a const_cast within the algorithm?
This would be very ugly :-(

Helmut


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