Skip to content
Snippets Groups Projects
Commit a4c439ec authored by Martin Nolte's avatar Martin Nolte
Browse files

Merge branch 'feature/test-comparison-of-forward-iterator' into 'master'

[test] check whether default-constructed forward iterators compare equal

See merge request dune-common!350
parents 5da55721 bba00364
No related branches found
No related tags found
No related merge requests found
......@@ -346,7 +346,7 @@ namespace Dune
inline ArrayListIterator<T,N,A>& operator=(const ArrayListIterator<T,N,A>& other);
//! Standard constructor
inline ArrayListIterator() : position_(0)
inline ArrayListIterator() : position_(0), list_(nullptr)
{}
private:
......@@ -441,7 +441,7 @@ namespace Dune
inline const ConstArrayListIterator<T,N,A>& operator=(const ConstArrayListIterator<T,N,A>& other);
inline ConstArrayListIterator() : position_(0)
inline ConstArrayListIterator() : position_(0), list_(nullptr)
{}
inline ConstArrayListIterator(const ArrayListIterator<T,N,A>& other);
......
......@@ -5,6 +5,7 @@
#define DUNE_ITERATORTEST_HH
#include <iostream>
#include <algorithm>
#include <dune/common/classname.hh>
#include <dune/common/typetraits.hh>
#include <dune/common/unused.hh>
......@@ -24,9 +25,16 @@ int testForwardIterator(Iter begin, Iter end, Opt& opt)
int ret=0;
// Test whether iterator is default-constructible
// This object will go out of scope at the end of this method, and hence
// it will also test whether the object is destructible.
Iter defaultConstructedIterator;
// These object will go out of scope at the end of this method, and hence
// it will also test whether these objects are destructible.
Iter defaultConstructedIterator1, defaultConstructedIterator2;
// Since C++14, default-constructed forward iterators are specified as the
// end iterator of the same, empty sequence. Hence, they should compare equal.
if (defaultConstructedIterator1 != defaultConstructedIterator2) {
std::cerr<<"Default constructed iterators do not compare equal for "+Dune::className<Iter>()+"."<<std::endl;
ret=1;
}
// Test whether iterator is copy-constructible
Iter tmp1(begin);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment