The problem in the code is a tiny error in class FindSum. Here is the correction:
for ( size_t i = 0 r.begin() ; i != r.end() ; i++ )
By the way, a little more performance might be obtained by using a local temporary variable to accumulate the sum, like this:
[cpp] double tmp = sum; for ( size_t i = r.begin(); i != r.end() ; i++ ) tmp += my_a; sum = tmp;[/cpp]
The reason it might help is that sometimes a compiler cannot tell that my_a and this->sum are not aliases for the same location, and thus has to be conservative about optimization. By accumulating the sum in a non-address-taken local temporary, you make clear that the location being updated inside the loop is not aliased to my_a.