From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2100) id 9238B393C88C; Sat, 22 Aug 2020 21:47:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9238B393C88C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1598132851; bh=EP0tFKUK/EFuGCZ9a4rs4fQQUddRely+DPU6Q8Mbi5k=; h=From:To:Subject:Date:From; b=YPzA2vE2gLzCyTH1zgbsrFa1PcFRbUKzBHyOv9sWE0vF6lEImKXf80jHxWyjdg0aq o9SI7W0vV7PvCs1+lz/A5MuJLOlI+1qBoD1F3jBUQM+NGLyoF/pCwdpuRisRulBrgw 6n3Oac05eI9zsvvN9PZGpUJeBmbWKvuTavgN+txc= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Giuliano Belinassi To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc/devel/autopar_devel] libstdc++: Fix __gnu_test::input_iterator_wrapper::operator++(int) X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/devel/autopar_devel X-Git-Oldrev: b6fcb09410ef58f621070ff27585a3a9b968c7b2 X-Git-Newrev: ed91d55958cbb8292565ffd2af10e9cfb8c5870d Message-Id: <20200822214731.9238B393C88C@sourceware.org> Date: Sat, 22 Aug 2020 21:47:31 +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: Sat, 22 Aug 2020 21:47:31 -0000 https://gcc.gnu.org/g:ed91d55958cbb8292565ffd2af10e9cfb8c5870d commit ed91d55958cbb8292565ffd2af10e9cfb8c5870d Author: Jonathan Wakely Date: Mon Jun 1 18:30:47 2020 +0100 libstdc++: Fix __gnu_test::input_iterator_wrapper::operator++(int) I noticed recently that our input_iterator_wrapper utility for writing tests has the following post-increment operator: void operator++(int) { ++*this; } That fails to meet the Cpp17InputIterator requirement that *r++ is valid. This change makes it return a non-void proxy type that can be deferenced to produce another proxy, which is convertible to the value_type. The second proxy converts to const T& to ensure it can't be written to. * testsuite/util/testsuite_iterators.h: (input_iterator_wrapper::operator++(int)): Return proxy object. Diff: --- libstdc++-v3/testsuite/util/testsuite_iterators.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h index 5be47f47915..71b672c85fa 100644 --- a/libstdc++-v3/testsuite/util/testsuite_iterators.h +++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h @@ -208,6 +208,17 @@ namespace __gnu_test : public std::iterator::type, std::ptrdiff_t, T*, T&> { + struct post_inc_proxy + { + struct deref_proxy + { + T* ptr; + operator const T&() const { return *ptr; } + } p; + + deref_proxy operator*() const { return p; } + }; + protected: input_iterator_wrapper() : ptr(0), SharedInfo(0) { } @@ -266,10 +277,12 @@ namespace __gnu_test return *this; } - void + post_inc_proxy operator++(int) { + post_inc_proxy tmp = { { ptr } }; ++*this; + return tmp; } #if __cplusplus >= 201103L