I implemented an iterator, which has Fibonacci numbers as output. In my main() I'd like to find a number which is dividable by 17 (it's 34). Why doesn't work my find_if statement.
Thank you!
#include <boost/operators.hpp>
#include <algorithm>
#include <tr1/functional>
struct FibIter: boost::input_iterator_helper<FibIter,unsigned long long> {
//typedef value_type unsigned long long;
FibIter(value_type l=0):counter(0), fib0(0),fib1(1){
while(l!=counter)
++(*this);
}
value_type operator*() const {return fib0;}
FibIter& operator++() {
++counter;
value_type fnew = fib0+fib1;
fib0 = fib1;
fib1 = fnew;
return *this;
}
bool operator==(FibIter const &other)const {
return counter == other.counter;
}
private:
value_type counter;
value_type fib0, fib1;
};
using namespace std;
using namespace tr1;
using namespace placeholders;
int main() {
FibIter found = find_if(FibIter(), FibIter(100),bind(not2(modulus<unsigned long long>()),_1,17ULL));
}