Three thoughts:
fn::operator()(int, int)
returns a bool
but has no return statement. That function is not proper C++.
When I fix that line, I get the output that I would expect. If the first part of the answer doesn't fix your problem, could you elaborate in your question with the output that you see, and the output that you expect, and a note about how they differ.
You're also incrementing an uninitialized variable fn::i
. This isn't going to do anything helpful for you. You should initialize it in a constructor. If you attempt to print this variable (or inspect it in any way), it could have any value, because it's starting value could have been anything (possibly 0, possibly anything else).
To elaborate, my compiler warned me of the following problem:
foo.cc:16:3: warning: control reaches end of non-void function [-Wreturn-type]
To fix this, I added a return false;
at the end of the functor, and I see the following output, which makes sense to me.
[11:47am][wlynch@watermelon /tmp] ./foo
what the poodles?
what the poodles?
what the poodles?
what the poodles?
what the poodles?
what the poodles?
what the poodles?
what the poodles?
what the poodles?
what the poodles?
what the poodles?
what the poodles?
what the poodles?
what the poodles?
what the poodles?
what the poodles?
what the poodles?
what the poodles?
Pomeranians!