From patchwork Thu Aug 27 19:05:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 511394 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 1146314018C for ; Fri, 28 Aug 2015 05:05:36 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=TzgXQ2w5; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=n04569FU0m8FOAkPSnkVMeZGn54313CQSCoyn/8fkaGRD7Cyq9Xk2 b3YdTrsDydWygXGhFZPBxSqYjvh6pVtMDWccL1eWUqSlsH/ctiRV/O36tQqndRnS R9XIZQ10faf0tpaRCyhHIjR3fqTtSfGG8beWzMkjs1LI1QsODIR6/A= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=MaPQ4Y4e06ilbOL7gBQ2V50ldlM=; b=TzgXQ2w5zPqOYajw3P03 vpOEsQPjTkkA9ObvmJvQZ2UaS0nx68e4HPQfwR4cD1nZ7swZvoIWOntx9npFtuQ2 HqJsSqsMK0YkF6M4hQ8shPGiW0snrYr8xgqXMM0OjG7POKTcwwdpXGSi4USrFnRQ Kff+lrM+YqzTc8TdkfrDDFM= Received: (qmail 47966 invoked by alias); 27 Aug 2015 19:05:21 -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 47890 invoked by uid 89); 27 Aug 2015 19:05:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 27 Aug 2015 19:05:18 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 9B8418E908; Thu, 27 Aug 2015 19:05:17 +0000 (UTC) Received: from localhost (ovpn-116-95.ams2.redhat.com [10.36.116.95]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7RJ5GrV017620; Thu, 27 Aug 2015 15:05:17 -0400 Date: Thu, 27 Aug 2015 20:05:16 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [patch] libstdc++/67374 declare valarray begin/end overloads in Message-ID: <20150827190516.GW2631@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.5.23 (2014-03-12) The std::cbegin function in can't call the std::begin function in unless it knows about it, so we need to declare the valarray overloads in . I considered adding a header with the declarations, but I don't think that's worth it, so I'm just declaring them directly in range_access.h Tested powerpc64le-linux, committed to trunk. I'll probably commit to the gcc-5 branch soon too. commit bc5fced738a428c267ef1921f2e95514ffafd093 Author: Jonathan Wakely Date: Thu Aug 27 18:44:59 2015 +0100 PR libstdc++/67374 * include/bits/range_access.h (valarray, begin, end): Declare. * testsuite/26_numerics/valarray/range_access.cc: Test const overloads. * testsuite/26_numerics/valarray/range_access2.cc: New. diff --git a/libstdc++-v3/include/bits/range_access.h b/libstdc++-v3/include/bits/range_access.h index aa78afb..01a05bc 100644 --- a/libstdc++-v3/include/bits/range_access.h +++ b/libstdc++-v3/include/bits/range_access.h @@ -98,6 +98,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __arr + _Nm; } #if __cplusplus >= 201402L + + template class valarray; + // These overloads must be declared for cbegin and cend to use them. + template _Tp* begin(valarray<_Tp>&); + template const _Tp* begin(const valarray<_Tp>&); + template _Tp* end(valarray<_Tp>&); + template const _Tp* end(const valarray<_Tp>&); + /** * @brief Return an iterator pointing to the first element of * the const container. diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc b/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc index eb8ca3e..2a929b5 100644 --- a/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc +++ b/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc @@ -28,4 +28,7 @@ test01() std::valarray va{1.0, 2.0, 3.0}; std::begin(va); std::end(va); + const auto& cva = va; + std::begin(cva); + std::end(cva); } diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/range_access2.cc b/libstdc++-v3/testsuite/26_numerics/valarray/range_access2.cc new file mode 100644 index 0000000..1c7a485 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/range_access2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++14" } + +// Copyright (C) 2015 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 +// . + +// 26.6.10 valarray range access: [valarray.range] + +#include +#include + +// PR libstdc++/67374 +void +test01() +{ + std::valarray va{1.0, 2.0, 3.0}; + std::cbegin(va); + std::cend(va); + const auto& cva = va; + std::cbegin(cva); + std::cend(cva); +}