From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@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 19:07:00 -0000 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-Type: multipart/mixed; boundary="sDKAb4OeUBrWWL6P" Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-08/txt/msg01740.txt.bz2 --sDKAb4OeUBrWWL6P Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-length: 460 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. --sDKAb4OeUBrWWL6P Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" Content-length: 3038 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); +} --sDKAb4OeUBrWWL6P--