Skip to content
Snippets Groups Projects
Commit 8bca983d authored by Christian Engwer's avatar Christian Engwer
Browse files

strict use of DifferenceType

[[Imported from SVN: r1980]]
parent f9fb8671
No related branches found
No related tags found
No related merge requests found
......@@ -85,20 +85,25 @@ namespace Dune {
* @brief Generic class for stl conformant iterators for container classes with operator[].
*
*/
template<class C, class T>
template<class C, class T, class D = std::ptrdiff_t>
class GenericIterator :
public Dune::RandomAccessIteratorFacade<GenericIterator<C,T>,T, T&, int>
public Dune::RandomAccessIteratorFacade<GenericIterator<C,T>,T, T&, D>
{
friend class GenericIterator<typename Dune::RemoveConst<C>::Type, typename Dune::RemoveConst<T>::Type >;
friend class GenericIterator<const typename Dune::RemoveConst<C>::Type, const typename Dune::RemoveConst<T>::Type >;
public:
/**
* @brief The type of the difference between two positions.
*/
typedef D DifferenceType;
// Constructors needed by the base iterators.
GenericIterator() : container_(0), position_(0)
{}
GenericIterator(C& cont, int pos)
GenericIterator(C& cont, DifferenceType pos)
: container_(&cont), position_(pos)
{}
......@@ -135,11 +140,11 @@ namespace Dune {
}
// Additional function needed by RandomAccessIterator
T& elementAt(int i) const {
T& elementAt(DifferenceType i) const {
return container_->operator[](position_+i);
}
void advance(int n){
void advance(DifferenceType n){
position_=position_+n;
}
......@@ -156,7 +161,7 @@ namespace Dune {
}
private:
C *container_;
size_t position_;
DifferenceType position_;
};
/** @} */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment