ball
ball copied to clipboard
BaseIterator difference_type typedef problematic
Currently BaseIterator defines the difference_type as Position. Unfortunately many Composite-derived classes define Position as Composite*, which makes no sense as a difference_type. This breaks compatibility of our iterators with many STL algorithms.
For example the following code does not compile:
#include <BALL/KERNEL/protein.h>
#include <algorithm>
using namespace BALL;
int main() {
Protein p;
std::count_if(p.beginResidue(), p.endResidue(),
std::mem_fn(&Residue::isSelected));
}
Changing BaseIterator::difference_type unconditionally to std::ptrdiff_t (the STL default) fixes this. However I am not certain that this is the correct fix. Any ideas?