From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2136) id 6A0EA3959C27; Wed, 17 Jun 2020 19:24:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A0EA3959C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592421862; bh=yVR2UQZ+79vHRCskYmY82WASZttDpyHl9rkMl+KgpoM=; h=From:To:Subject:Date:From; b=u579goJeLMQtCod3934CdbEo/eNYTkDA8yU0WHK7mkda1VrF/wu8cjSfR7MdFLjYz eKVWmLWNu4YGZbxikvCvUdb3+c5rPjFNiytgBNs3QTuwYoVkCaaBskwT5Z7QVpiYHN iUFH2hXFleC7NSC+J/oJGGFq9OKrl8mvlq/MDl8U= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Aldy Hernandez To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc/devel/ranger] libstdc++: Add a move-only testsuite iterator type X-Act-Checkin: gcc X-Git-Author: Patrick Palka X-Git-Refname: refs/heads/devel/ranger X-Git-Oldrev: 05779e2c89e06d09a6b685797e87723f7906a5ce X-Git-Newrev: d6d4b339f5b77070ee9ae896c2f20ba315b7b7e0 Message-Id: <20200617192422.6A0EA3959C27@sourceware.org> Date: Wed, 17 Jun 2020 19:24:22 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2020 19:24:22 -0000 https://gcc.gnu.org/g:d6d4b339f5b77070ee9ae896c2f20ba315b7b7e0 commit d6d4b339f5b77070ee9ae896c2f20ba315b7b7e0 Author: Patrick Palka Date: Mon Mar 2 16:21:33 2020 -0500 libstdc++: Add a move-only testsuite iterator type This adds a move-only testsuite iterator wrapper to which will be used in the tests for LWG 3355. The tests for LWG 3389 and 3390 are adjusted to use this new iterator wrapper. libstdc++-v3/ChangeLog: * testsuite/util/testsuite_iterators.h (input_iterator_wrapper_nocopy): New testsuite iterator. * testsuite/24_iterators/counted_iterator/lwg3389.cc: Use it. * testsuite/24_iterators/move_iterator/lwg3390.cc: Likewise. Diff: --- libstdc++-v3/ChangeLog | 5 ++++ .../24_iterators/counted_iterator/lwg3389.cc | 35 ++-------------------- .../24_iterators/move_iterator/lwg3390.cc | 35 ++-------------------- libstdc++-v3/testsuite/util/testsuite_iterators.h | 28 +++++++++++++++++ 4 files changed, 37 insertions(+), 66 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 45ff06d4ea7..1d68f7ceaac 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,10 @@ 2020-03-04 Patrick Palka + * testsuite/util/testsuite_iterators.h (input_iterator_wrapper_nocopy): + New testsuite iterator. + * testsuite/24_iterators/counted_iterator/lwg3389.cc: use it. + * testsuite/24_iterators/move_iterator/lwg3390.cc: Likewise. + * include/bits/ranges_uninitialized.h (uninitialized_copy_fn::operator()): Pass a reference type as the first argument to is_nothrow_assignable_v. diff --git a/libstdc++-v3/testsuite/24_iterators/counted_iterator/lwg3389.cc b/libstdc++-v3/testsuite/24_iterators/counted_iterator/lwg3389.cc index cf74fd47bec..8b9bf53f6c5 100644 --- a/libstdc++-v3/testsuite/24_iterators/counted_iterator/lwg3389.cc +++ b/libstdc++-v3/testsuite/24_iterators/counted_iterator/lwg3389.cc @@ -23,44 +23,13 @@ #include using __gnu_test::test_range; -using __gnu_test::input_iterator_wrapper; - -template -struct move_only_wrapper : input_iterator_wrapper -{ - using input_iterator_wrapper::input_iterator_wrapper; - - move_only_wrapper() - : input_iterator_wrapper(nullptr, nullptr) - { } - - move_only_wrapper(const move_only_wrapper&) = delete; - move_only_wrapper& - operator=(const move_only_wrapper&) = delete; - - move_only_wrapper(move_only_wrapper&&) = default; - move_only_wrapper& - operator=(move_only_wrapper&&) = default; - - using input_iterator_wrapper::operator++; - - move_only_wrapper& - operator++() - { - input_iterator_wrapper::operator++(); - return *this; - } -}; - -static_assert(std::input_iterator>); -static_assert(!std::forward_iterator>); -static_assert(!std::copyable>); +using __gnu_test::input_iterator_wrapper_nocopy; // LWG 3389 void test01() { int x[] = {1,2,3,4}; - test_range rx(x); + test_range rx(x); auto it = std::counted_iterator(rx.begin(), 2); } diff --git a/libstdc++-v3/testsuite/24_iterators/move_iterator/lwg3390.cc b/libstdc++-v3/testsuite/24_iterators/move_iterator/lwg3390.cc index 1df7caccece..7e9f4a0d0cc 100644 --- a/libstdc++-v3/testsuite/24_iterators/move_iterator/lwg3390.cc +++ b/libstdc++-v3/testsuite/24_iterators/move_iterator/lwg3390.cc @@ -23,44 +23,13 @@ #include using __gnu_test::test_range; -using __gnu_test::input_iterator_wrapper; - -template -struct move_only_wrapper : input_iterator_wrapper -{ - using input_iterator_wrapper::input_iterator_wrapper; - - move_only_wrapper() - : input_iterator_wrapper(nullptr, nullptr) - { } - - move_only_wrapper(const move_only_wrapper&) = delete; - move_only_wrapper& - operator=(const move_only_wrapper&) = delete; - - move_only_wrapper(move_only_wrapper&&) = default; - move_only_wrapper& - operator=(move_only_wrapper&&) = default; - - using input_iterator_wrapper::operator++; - - move_only_wrapper& - operator++() - { - input_iterator_wrapper::operator++(); - return *this; - } -}; - -static_assert(std::input_iterator>); -static_assert(!std::forward_iterator>); -static_assert(!std::copyable>); +using __gnu_test::input_iterator_wrapper_nocopy; // LWG 3390 void test01() { int x[] = {1,2,3,4}; - test_range rx(x); + test_range rx(x); auto it = std::make_move_iterator(rx.begin()); } diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h index 417dff23c50..e47b2b03e40 100644 --- a/libstdc++-v3/testsuite/util/testsuite_iterators.h +++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h @@ -674,6 +674,34 @@ namespace __gnu_test { return iter -= n; } }; + // A move-only input iterator type. + template + struct input_iterator_wrapper_nocopy : input_iterator_wrapper + { + using input_iterator_wrapper::input_iterator_wrapper; + + input_iterator_wrapper_nocopy() + : input_iterator_wrapper(nullptr, nullptr) + { } + + input_iterator_wrapper_nocopy(const input_iterator_wrapper_nocopy&) = delete; + input_iterator_wrapper_nocopy& + operator=(const input_iterator_wrapper_nocopy&) = delete; + + input_iterator_wrapper_nocopy(input_iterator_wrapper_nocopy&&) = default; + input_iterator_wrapper_nocopy& + operator=(input_iterator_wrapper_nocopy&&) = default; + + using input_iterator_wrapper::operator++; + + input_iterator_wrapper_nocopy& + operator++() + { + input_iterator_wrapper::operator++(); + return *this; + } + }; + // A type meeting the minimum std::range requirements template class Iter> class test_range