Boost logo

Boost :

Subject: Re: [boost] [range] fat iterators?
From: Jonathan Wakely (jwakely.boost_at_[hidden])
Date: 2013-11-07 15:49:11


On 7 November 2013 17:27, Nathan Ridge wrote:
>
> Jeffrey Yaskin posted a candidate design, implemented for filter_iterator,
> here: https://svn.boost.org/trac/boost/ticket/7630
>
> What do you think about this design?

That's beautiful!

My solution to the temporary range problem is simpler, but as
mentioned in Jeffrey's patch to the docs, for ranges that store an
iterator pair it wastes the space of a reference member in the lvalue
case, and doesn't vanish to nothing in C++03 mode:

template<typename R>
class adaptor
{
  R r; // R is a range or an lvalue-reference-to-range

public:
  explicit
  adaptor(R&& r) : r(std::forward<R>(r)) { }

  // ...
};

template<typename R>
adaptor<R>
adapted(R&& r)
{ return adaptor<R>{std::forward<R>(r)}; }


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