$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-users] [Iterator] filter_iterator over greedy?
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2013-01-07 08:49:40
Hi Folks,
Somewhat to my surprise this code, simply creating a filter_iterator,
evaluates the predicate
until an element satisfying the predicate is found. This seems wrong to me.
Shouldn't evaluation
of the predicate be delayed until the filter_iterator is dereferenced?
Thx, Rob.
#include <iostream>
#include <boost/range.hpp>
#include <boost/iterator/filter_iterator.hpp>
bool predicate( int i )
{
std::cout << "predicate(" << i << ")" << std::endl;
return true;
}
int main( )
{
int array[] = { 0, 1 };
boost::make_filter_iterator( predicate, boost::begin( array ),
boost::end( array ) );
}
> [Run]
predicate(0)
>