[libcxx] r252407 - Implement LWG#2353: std::next is over-constrained
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 7 09:48:49 PST 2015
Author: marshall
Date: Sat Nov 7 11:48:49 2015
New Revision: 252407
URL: http://llvm.org/viewvc/llvm-project?rev=252407&view=rev
Log:
Implement LWG#2353: std::next is over-constrained
Modified:
libcxx/trunk/include/iterator
libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
libcxx/trunk/www/cxx1z_status.html
Modified: libcxx/trunk/include/iterator
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=252407&r1=252406&r2=252407&view=diff
==============================================================================
--- libcxx/trunk/include/iterator (original)
+++ libcxx/trunk/include/iterator Sat Nov 7 11:48:49 2015
@@ -513,12 +513,12 @@ distance(_InputIter __first, _InputIter
return __distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
}
-template <class _ForwardIter>
+template <class _InputIter>
inline _LIBCPP_INLINE_VISIBILITY
-_ForwardIter
-next(_ForwardIter __x,
- typename iterator_traits<_ForwardIter>::difference_type __n = 1,
- typename enable_if<__is_forward_iterator<_ForwardIter>::value>::type* = 0)
+_InputIter
+next(_InputIter __x,
+ typename iterator_traits<_InputIter>::difference_type __n = 1,
+ typename enable_if<__is_input_iterator<_InputIter>::value>::type* = 0)
{
_VSTD::advance(__x, __n);
return __x;
Modified: libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp?rev=252407&r1=252406&r2=252407&view=diff
==============================================================================
--- libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp Sat Nov 7 11:48:49 2015
@@ -12,6 +12,8 @@
// template <InputIterator Iter>
// Iter next(Iter x, Iter::difference_type n = 1);
+// LWG #2353 relaxed the requirement on next from ForwardIterator to InputIterator
+
#include <iterator>
#include <cassert>
@@ -34,11 +36,13 @@ test(It i, It x)
int main()
{
const char* s = "1234567890";
+ test(input_iterator<const char*>(s), 10, input_iterator<const char*>(s+10));
test(forward_iterator<const char*>(s), 10, forward_iterator<const char*>(s+10));
test(bidirectional_iterator<const char*>(s), 10, bidirectional_iterator<const char*>(s+10));
test(random_access_iterator<const char*>(s), 10, random_access_iterator<const char*>(s+10));
test(s, 10, s+10);
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+1));
test(forward_iterator<const char*>(s), forward_iterator<const char*>(s+1));
test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1));
test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1));
Modified: libcxx/trunk/www/cxx1z_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=252407&r1=252406&r2=252407&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Sat Nov 7 11:48:49 2015
@@ -164,7 +164,7 @@
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2259">2259</a></td><td>Issues in 17.6.5.5 rules for member functions</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2273">2273</a></td><td><tt>regex_match</tt> ambiguity</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2336">2336</a></td><td><tt>is_trivially_constructible/is_trivially_assignable</tt> traits are always false</td><td>Kona</td><td></td></tr>
- <tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2353">2353</a></td><td><tt>std::next</tt> is over-constrained</td><td>Kona</td><td></td></tr>
+ <tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2353">2353</a></td><td><tt>std::next</tt> is over-constrained</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2367">2367</a></td><td><tt>pair</tt> and <tt>tuple</tt> are not correctly implemented for <tt>is_constructible</tt> with no args</td><td>Kona</td><td>Patch Ready</td></tr>
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2380">2380</a></td><td>May <tt><cstdlib></tt> provide <tt>long ::abs(long)</tt> and <tt>long long ::abs(long long)</tt>?</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2384">2384</a></td><td>Allocator's <tt>deallocate</tt> function needs better specification</td><td>Kona</td><td>Complete</td></tr>
More information about the cfe-commits
mailing list