From patchwork Mon Feb 24 23:26:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1243699 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-520039-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=mRaxc+/I; 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=IHEOAHS2; 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 48RJCC2SWgz9sRJ for ; Tue, 25 Feb 2020 10:28:07 +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:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=MsYokW5/81eI4PHnFgGI7gu4bxTp+JS+FItd1GAMLDz8iFr3qZCsk TZDnTF2nm3ZPh8lXwfx16hZcwobQfoSTfAp/W47ocfpz3dMxV2L0urjTqDxhCrZi QW3wdfWuIzMxt1hgzdIykIvta+0S86WSfyXk+psLv6dHW59giTpHQM= 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:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=default; bh=k/45p/Y5IYQMg0F9dU3w+1lmnG0=; b=mRaxc+/IrV6NrApnHcJpEpr9tEbK YLnCkMOKVj8gnbykiezYdkJaVRJhni4sIqWjqcBOXnyp9c6FeeMp2hLx8C0zukzD zacIuVJibvlc5GTFPp2Pu0j0bZeOKVqydS3RDuhPqx+YIGdcesPZ9iStZ6Jcr8e3 DUVcbtpFXvylogI= Received: (qmail 114112 invoked by alias); 24 Feb 2020 23:27:03 -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 113915 invoked by uid 89); 24 Feb 2020 23:27:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (205.139.110.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Feb 2020 23:27:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582586819; 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: in-reply-to:in-reply-to:references:references; bh=HYQwd4oQ2hWOM9HjDMpB8B7GvwETsmFhY2DiDTh3PSc=; b=IHEOAHS29NYBRVgyP54ubNO+q9jw+Xdr5d1RX08TKf0rMxv2PqD/GQwuiWnDI6xxxs+Da9 a+YIbf8xXZYtq3qrywLWT6H+jR1HytJ31DCbL5iaF96QQdtukZg472EGNOUcz19DJWw/at vuEj8fmrJWVBQxnT50T9JqHJPyAe8OI= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-466-tctAbeP_N269PY0SchzvBA-1; Mon, 24 Feb 2020 18:26:54 -0500 Received: by mail-qv1-f69.google.com with SMTP id z9so10723344qvo.10 for ; Mon, 24 Feb 2020 15:26:54 -0800 (PST) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id p126sm6547463qkd.108.2020.02.24.15.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 15:26:53 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, jwakely@redhat.com, Patrick Palka Subject: [PATCH] libstdc++: LWG 3325 Constrain return type of transformation function for transform_view Date: Mon, 24 Feb 2020 18:26:42 -0500 Message-Id: <20200224232643.851356-4-ppalka@redhat.com> In-Reply-To: <20200224232643.851356-1-ppalka@redhat.com> References: <20200224232643.851356-1-ppalka@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes libstdc++-v3/ChangeLog: LWG 3325 Constrain return type of transformation function for transform_view * include/std/ranges (transform_view): Constrain the return type of the transformation function as per LWG 3325. * testsuite/std/ranges/adaptors/lwg3325_neg.cc: New test. --- libstdc++-v3/include/std/ranges | 2 ++ .../std/ranges/adaptors/lwg3325_neg.cc | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 libstdc++-v3/testsuite/std/ranges/adaptors/lwg3325_neg.cc diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index ffdd3367b05..442d1d08098 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -1540,6 +1540,8 @@ namespace views template requires view<_Vp> && is_object_v<_Fp> && regular_invocable<_Fp&, range_reference_t<_Vp>> + && std::__detail::__can_reference>> class transform_view : public view_interface> { private: diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/lwg3325_neg.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/lwg3325_neg.cc new file mode 100644 index 00000000000..ac174714574 --- /dev/null +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/lwg3325_neg.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2020 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +namespace ranges = std::ranges; +namespace views = std::views; + +void +test01() +{ + auto f = [] (int x) { }; + int x[] = {1}; + auto v = ranges::transform_view{x, f}; // { dg-error "deduction failed|no match" } +} + +// { dg-prune-output "constraint failure" } +// { dg-prune-output "in requirements" }