Skip to content
Snippets Groups Projects
Commit 9ed7796a authored by Markus Blatt's avatar Markus Blatt
Browse files

Not all iterators have be sortable

[[Imported from SVN: r4912]]
parent a518524c
Branches
Tags
No related merge requests found
......@@ -195,17 +195,33 @@ int testConstIterator(Iter& begin, Iter& end, Opt& opt)
return ret;
}
template<class Container, typename IteratorTag>
void testSorting(Container& C, IteratorTag tag)
{ }
template<class Container>
void testSorting(Container& c, std::random_access_iterator_tag)
template<bool>
struct TestSorting
{
std::sort(c.begin(), c.end());
template<class Container, typename IteratorTag>
static void testSorting(Container& c, IteratorTag tag)
{}
template<class Container>
static void testSorting(Container& c, std::random_access_iterator_tag)
{
std::sort(c.begin(), c.end());
}
}
;
template<class Container, class Opt>
template<>
struct TestSorting<false>
{
template<class Container>
static void testSorting(Container& c, std::random_access_iterator_tag)
{}
template<class Container, typename IteratorTag>
static void testSorting(Container& c, IteratorTag tag)
{}
};
template<class Container, class Opt, bool testSort>
int testIterator(Container& c, Opt& opt)
{
typename Container::iterator begin=c.begin(), end=c.end();
......@@ -214,10 +230,9 @@ int testIterator(Container& c, Opt& opt)
typename Container::const_iterator cend=c.end();
int ret = 0;
testSorting(c, typename std::iterator_traits<typename Container::iterator>::iterator_category());
TestSorting<testSort>::testSorting(c, typename std::iterator_traits<typename Container::iterator>::iterator_category());
if(end!=cend ||
cend!=end)
if(end!=cend || cend!=end)
{
std::cerr<<"constant and mutable iterators should be equal!"<<std::endl;
ret=1;
......@@ -226,6 +241,12 @@ int testIterator(Container& c, Opt& opt)
testIterator(begin,end,opt);
}
template<class Container, class Opt>
int testIterator(Container& c, Opt& opt)
{
testIterator<Container,Opt,true>(c,opt);
}
template<class Iter, class Opt>
void testAssignment(Iter begin, Iter end, Opt& opt)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment