Subject: Re: [boost] Proposed interface change to boost::algorithm::copy_while
From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2013-02-20 21:28:17
On Feb 20, 2013, at 4:05 PM, Nathan Ridge <zeratul976_at_[hidden]> wrote:
>>> I'm proposing to change the interface to:
>>> template<typename InputIterator, typename OutputIterator, typename
>>> 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!)
> An alternative would be to take the 'first' iterator by reference.
> Boost.Spirit uses this approach.
I've thought about that (and actually used it internally in boost::hex).
However, for a public interface, I don't like it, because (among other things) it makes multi-threaded code harder to write.
Marshall Clow Idio Software <mailto:mclow.lists_at_[hidden]>
A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
-- Yu Suzuki
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk