Fix path::iterator post-increment and post-decrement
Backport from mainline 2017-10-19 Jonathan Wakely <jwakely@redhat.com> * include/experimental/bits/fs_path.h (path::iterator++(int)) (path::iterator--(int)): Fix for paths with only one component. * testsuite/experimental/filesystem/path/itr/traversal.cc: Test post-increment and post-decrement. From-SVN: r253942
This commit is contained in:
parent
47ffadd915
commit
24aeb1b939
@ -1,3 +1,13 @@
|
||||
2017-10-20 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
Backport from mainline
|
||||
2017-10-19 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
* include/experimental/bits/fs_path.h (path::iterator++(int))
|
||||
(path::iterator--(int)): Fix for paths with only one component.
|
||||
* testsuite/experimental/filesystem/path/itr/traversal.cc: Test
|
||||
post-increment and post-decrement.
|
||||
|
||||
2017-09-21 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
* testsuite/25_algorithms/clamp/1.cc: Fix order of arguments and
|
||||
|
@ -724,10 +724,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||
pointer operator->() const { return std::__addressof(**this); }
|
||||
|
||||
iterator& operator++();
|
||||
iterator operator++(int) { auto __tmp = *this; ++_M_cur; return __tmp; }
|
||||
iterator operator++(int) { auto __tmp = *this; ++*this; return __tmp; }
|
||||
|
||||
iterator& operator--();
|
||||
iterator operator--(int) { auto __tmp = *this; --_M_cur; return __tmp; }
|
||||
iterator operator--(int) { auto __tmp = *this; --*this; return __tmp; }
|
||||
|
||||
friend bool operator==(const iterator& __lhs, const iterator& __rhs)
|
||||
{ return __lhs._M_equals(__rhs); }
|
||||
|
@ -79,9 +79,28 @@ test02()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test03()
|
||||
{
|
||||
path paths[] = { "single", "multiple/elements" };
|
||||
for (const path& p : paths)
|
||||
for (auto iter = p.begin(); iter != p.end(); ++iter)
|
||||
{
|
||||
auto iter2 = iter;
|
||||
++iter;
|
||||
iter2++;
|
||||
VERIFY( iter2 == iter );
|
||||
auto iter3 = iter;
|
||||
--iter3;
|
||||
iter2--;
|
||||
VERIFY( iter2 == iter3 );
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
test03();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user