Boost logo

Boost :

Subject: Re: [boost] Proposed interface change to boost::algorithm::copy_while
From: Jeff Flinn (Jeffrey.Flinn_at_[hidden])
Date: 2013-02-21 11:40:18

On 2/21/2013 11:23 AM, Marshall Clow wrote:
> On Feb 20, 2013, at 1:05 PM, Neil Groves <neil_at_[hidden]> wrote:
>> On Wed, Feb 20, 2013 at 6:55 PM, Marshall Clow <mclow.lists_at_[hidden]>wrote:
>>> I'm proposing to change the interface to:
>>> template<typename InputIterator, typename OutputIterator, typename
>>> Predicate>
>>> std::pair<InputIterator, OutputIterator>
>>> copy_while ( InputIterator first, InputIterator last,
>>> OutputIterator result, Predicate p );
>>> i.e, changing the return type to return both iterators.
>> I think that certainly a change needs to be made to accomodate the extra
>> information. I wonder how wise it is to return a pair that when the
>> InputIterator type is the same as the OutputIterator type that it could be
>> mistaken for, and accepted by, range algorithms as input? (That's my fault
>> - doh!)
> Whoa. That's something I didn't know about. Boost.Range will take std::pair<Iter, Iter> as a range?
> Off to do more reading. ;-)

FYI, std::mismatch returns a pair of possibly unrelated iterators,

template <class InputIterator1, class InputIterator2>
   pair<InputIterator1, InputIterator2>
     mismatch (InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2 )

In the case of std::mismatch both iterators have an arguably higher
probability to be the same type.


Boost list run by bdawes at, gregod at, cpdaniel at, john at