From patchwork Fri Feb 7 18:59:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1235109 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-519149-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=jFjq2sDJ; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FTtc6acN; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Dl401bJXz9sRK for ; Sat, 8 Feb 2020 06:00:13 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=VptpyQIjhJvj75PK IG2We35tGjRrF+R2s2KMycmIOHsCAJfTWaZX7EvMJclUgjwycOeF+o8yympVagaL aK1phDKzjbsx4w0V9T590x0Q3jfUQyeqb2nRf1zb7JgXug2wOQdoFWV9ZNdb9LUK Qbd1VymwjsxP2LGM5MgZdJggPlI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=hhHw/ZoaBDhkUxHPcTJlPe 4elA4=; b=jFjq2sDJOlhyBSS7qXGtrHJKgVdVf8J7hfGEcBYE2m5Z9DgcTSr6DL OJDOZKZrEDeR9sTodGj4aCp05/ncF+BTvm47Z3WWd3aD/hCCe7OMPxyN70x298j9 VarN5T0Dn/9BUEguSlRxdchQUiPimknnL5lZ4C/lTVA6f0XePqnWo= Received: (qmail 123409 invoked by alias); 7 Feb 2020 19:00:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 123362 invoked by uid 89); 7 Feb 2020 19:00:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Feb 2020 19:00:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581102000; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QzOxULnmqRVCba54PKSQt0m7XZkcfexYw6a7mm+OFSw=; b=FTtc6acNrqb/jXNk8+unx7QB1IPlOQpCNU9wS4VKbSLpYjw8H5pJDQGTuKB8ds6Ybm6VtT pUiOxlflKVI/jcrTknuzPzxkByRvYwdQAldZdCHnBrMdiafwWbqPaaIMfGiVxyA+fX/oyW Mrtse/wxHOaJ+x+X6vc2Sy37LLgQscY= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-219-A4tYLIbhPPubMd5prWWKRw-1; Fri, 07 Feb 2020 13:59:58 -0500 Received: by mail-qt1-f199.google.com with SMTP id l25so169400qtu.0 for ; Fri, 07 Feb 2020 10:59:58 -0800 (PST) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id s42sm1789480qtk.87.2020.02.07.10.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2020 10:59:56 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, jwakely@redhat.com, Patrick Palka Subject: [PATCH] libstdc++: Make sure iterator_traits is populated Date: Fri, 7 Feb 2020 13:59:26 -0500 Message-Id: <20200207185926.1861315-1-ppalka@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes Since basic_istream_view::iterator is neither a cpp17 iterator (because it's move-only) nor does it define all four of the types {difference_type, value_type, reference, iterator_category}, then by the rule in [iterator.traits], its iterator_traits has no members. More concretely this means that it can't e.g. be composed with a views::transform or a views::filter because they look at the iterator_traits of the underlying view. This seems to be a defect in the current spec. libstdc++-v3/ChangeLog: * include/std/ranges (ranges::basic_istream_view::iterator::reference): Define it so that this iterator's iterator_traits is populated. * testsuite/std/ranges/istream_view.cc: Augment test. --- libstdc++-v3/include/std/ranges | 1 + libstdc++-v3/testsuite/std/ranges/istream_view.cc | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 891ecf75eff..6e982d6ded3 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -996,6 +996,7 @@ namespace views using iterator_category = input_iterator_tag; using difference_type = ptrdiff_t; using value_type = _Val; + using reference = _Val&; _Iterator() = default; diff --git a/libstdc++-v3/testsuite/std/ranges/istream_view.cc b/libstdc++-v3/testsuite/std/ranges/istream_view.cc index 1729459bce3..7feb3ff4b0a 100644 --- a/libstdc++-v3/testsuite/std/ranges/istream_view.cc +++ b/libstdc++-v3/testsuite/std/ranges/istream_view.cc @@ -68,10 +68,21 @@ test03() VERIFY( ranges::equal(v, (int[]){0,1,2,3,4}) ); } +void +test04() +{ + std::string s = "0123456789"; + auto ss = std::istringstream{s}; + static_assert(ranges::input_range(ss))>); + auto v = ranges::istream_view(ss) | views::transform(&X::c); + VERIFY( ranges::equal(v, s) ); +} + int main() { test01(); test02(); test03(); + test04(); }