Create a 'comma_iterator' class that overloads operator, and asserts when it's called. Add tests to mismatch to make sure it can't be blindsided by such an evil iterator. More tests for other algorithms forthcoming. Thanks to STL for pointing this out at CppCon and Yakov Galka for opening LWG issue #2133
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@217902 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -36,6 +36,14 @@ int main()
|
||||
input_iterator<const int*>(ia+3),
|
||||
input_iterator<const int*>(ib+3))));
|
||||
|
||||
assert(std::mismatch(comma_iterator<const int*>(ia),
|
||||
comma_iterator<const int*>(ia + sa),
|
||||
comma_iterator<const int*>(ib)) ==
|
||||
(std::pair<comma_iterator<const int*>,
|
||||
comma_iterator<const int*> >(
|
||||
comma_iterator<const int*>(ia+3),
|
||||
comma_iterator<const int*>(ib+3))));
|
||||
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::mismatch(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa),
|
||||
|
@@ -39,6 +39,14 @@ int main()
|
||||
input_iterator<const int*> >(
|
||||
input_iterator<const int*>(ia+3),
|
||||
input_iterator<const int*>(ib+3))));
|
||||
assert(std::mismatch(comma_iterator<const int*>(ia),
|
||||
comma_iterator<const int*>(ia + sa),
|
||||
comma_iterator<const int*>(ib),
|
||||
std::equal_to<int>()) ==
|
||||
(std::pair<comma_iterator<const int*>,
|
||||
comma_iterator<const int*> >(
|
||||
comma_iterator<const int*>(ia+3),
|
||||
comma_iterator<const int*>(ib+3))));
|
||||
#ifdef HAS_FOUR_ITERATOR_VERSION
|
||||
assert(std::mismatch(input_iterator<const int*>(ia),
|
||||
input_iterator<const int*>(ia + sa),
|
||||
|
Reference in New Issue
Block a user