I need an iterator for my custom random access collection class. I want to use the iterator with std::sort. As I'm a C++ newbee with a limited time budget, I'd like to avoid writing the whole thing myself.
My iterator is basically just a simple size_t. Therefore, I thought boost::counting_iterator could be a good match. Once I had completed the Incrementable I had to realize that counting_iterator defines its reference type as const Incrementable&.
Although I'm still confused by a lot of C++, I believe this will prevent me from using the iterator with std::sort because const iterators can not be used to swap collection elements.
Here is the question: why does boost::counting_iterator define its reference type as const and, probably more important, what should I use instead?