diff options
author | Ville Voutilainen <ville.voutilainen@gmail.com> | 2017-11-20 16:21:42 +0200 |
---|---|---|
committer | Ville Voutilainen <ville@gcc.gnu.org> | 2017-11-20 16:21:42 +0200 |
commit | 7b7b60c83047db2e4bde9e7f40ce3f1738694789 (patch) | |
tree | 18ee860194c5bf079e48a6f3b5f0de4836e5242b /libstdc++-v3 | |
parent | 9cdcebf971e71e69a773d729b97cfb55652cca31 (diff) | |
download | gcc-7b7b60c83047db2e4bde9e7f40ce3f1738694789.zip gcc-7b7b60c83047db2e4bde9e7f40ce3f1738694789.tar.gz gcc-7b7b60c83047db2e4bde9e7f40ce3f1738694789.tar.bz2 |
Implement LWG 2353
* include/bits/stl_iterator_base_funcs.h (next):
Use InputIterator instead of ForwardIterator.
* testsuite/24_iterators/operations/lwg2353.cc: New.
* testsuite/24_iterators/operations/next_neg.cc: Remove.
From-SVN: r254957
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_iterator_base_funcs.h | 11 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/24_iterators/operations/lwg2353.cc | 26 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/24_iterators/operations/next_neg.cc | 42 |
4 files changed, 39 insertions, 48 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 15936ac..bdb7de2 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2017-11-20 Ville Voutilainen <ville.voutilainen@gmail.com> + + Implement LWG 2353 + * include/bits/stl_iterator_base_funcs.h (next): + Use InputIterator instead of ForwardIterator. + * testsuite/24_iterators/operations/lwg2353.cc: New. + * testsuite/24_iterators/operations/next_neg.cc: Remove. + 2017-11-18 Edward Smith-Rowland <3dw4rd@verizon.net> PR libstdc++/pr66689 - comp_ellint_3 and ellint_3 return garbage values diff --git a/libstdc++-v3/include/bits/stl_iterator_base_funcs.h b/libstdc++-v3/include/bits/stl_iterator_base_funcs.h index 86a93d3..ad84b39 100644 --- a/libstdc++-v3/include/bits/stl_iterator_base_funcs.h +++ b/libstdc++-v3/include/bits/stl_iterator_base_funcs.h @@ -208,14 +208,13 @@ _GLIBCXX_END_NAMESPACE_CONTAINER #if __cplusplus >= 201103L - template<typename _ForwardIterator> - inline _GLIBCXX17_CONSTEXPR _ForwardIterator - next(_ForwardIterator __x, typename - iterator_traits<_ForwardIterator>::difference_type __n = 1) + template<typename _InputIterator> + inline _GLIBCXX17_CONSTEXPR _InputIterator + next(_InputIterator __x, typename + iterator_traits<_InputIterator>::difference_type __n = 1) { // concept requirements - __glibcxx_function_requires(_ForwardIteratorConcept< - _ForwardIterator>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) std::advance(__x, __n); return __x; } diff --git a/libstdc++-v3/testsuite/24_iterators/operations/lwg2353.cc b/libstdc++-v3/testsuite/24_iterators/operations/lwg2353.cc new file mode 100644 index 0000000..13b058b --- /dev/null +++ b/libstdc++-v3/testsuite/24_iterators/operations/lwg2353.cc @@ -0,0 +1,26 @@ +// { dg-options "-D_GLIBCXX_CONCEPT_CHECKS" } +// { dg-do run { target c++11 } } + +#include <iterator> +#include <utility> +#include <sstream> +#include <string> +#include <testsuite_hooks.h> + +template<typename Distance, typename InputRange> +std::pair<std::istream_iterator<char>, std::istream_iterator<char>> +drop(Distance n, InputRange& rng) +{ + return std::make_pair(std::next(std::istream_iterator<char>(rng), n), + std::istream_iterator<char>() + ); +} + +int main() +{ + std::stringstream x("let let there be rock"); + x << std::noskipws; + auto y = drop(4, x); + std::string z(y.first, y.second); + VERIFY(z == "let there be rock"); +} diff --git a/libstdc++-v3/testsuite/24_iterators/operations/next_neg.cc b/libstdc++-v3/testsuite/24_iterators/operations/next_neg.cc deleted file mode 100644 index f3c20a1..0000000 --- a/libstdc++-v3/testsuite/24_iterators/operations/next_neg.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2015-2017 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// <http://www.gnu.org/licenses/>. - -// { dg-options "-D_GLIBCXX_CONCEPT_CHECKS" } -// { dg-do compile { target c++11 } } - -#include <iterator> - -struct X {}; - -namespace std -{ - template<> - struct iterator_traits<const X*> : iterator_traits<X*> - { - using iterator_category = input_iterator_tag; - using reference = const X&; - using pointer = const X*; - }; -} - -void -test01() -{ - const X array[1] = { }; - std::next(array); - // { dg-error "input_iterator" "" { target *-*-* } 220 } -} |