
On 2/21/2013 11:23 AM, Marshall Clow wrote:
On Feb 20, 2013, at 1:05 PM, Neil Groves <neil@grovescomputing.com> wrote:
On Wed, Feb 20, 2013 at 6:55 PM, Marshall Clow <mclow.lists@gmail.com>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. Jeff