From patchwork Sat Nov 9 01:15:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Smith-Rowland, Edward M" X-Patchwork-Id: 1192350 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-512871-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=alionscience.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="UuWBzCyb"; 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 478zjh6Fxvz9sP4 for ; Sat, 9 Nov 2019 12:16:06 +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:content-type:mime-version; q=dns; s=default; b=Mfxc3MsXG3Ix/zRcxh0XzVlU8xiXl87ar+VvQUX+psNnuFCQ08 a/og/C/Zovco5qRB/Z3WMbdtxlHpqlls6341XwdDDd0L4OA7PI6fe96v97DKmJDg WYlSSh/GCoW4RT4L4Xio601Fi2EZ9aN/Ko+Izo0XZOQZGGqgPtTyiPFmI= 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:content-type:mime-version; s= default; bh=fPBIrYu1deunaCQ/GtBv4YQGnog=; b=UuWBzCybpL90i5N5hkSe FYvhA4eY1vhqOP1UVQv+JWytwL4y9TCtEuATiK595GXQzib7fU9hM+99x6Nj0a9X njJR/HVSNbD/P+aAQW/YgimjcUEyOa421U61rFjw01rpqkzkICQn9mS6ho76h7/I 1lXZKMHZdSv4GCLpzHuvWL0= Received: (qmail 90909 invoked by alias); 9 Nov 2019 01:15:58 -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 90884 invoked by uid 89); 9 Nov 2019 01:15:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=Edward, edward, H*c:HHH X-HELO: mfilt1.alionscience.com Received: from mfilt1.alionscience.com (HELO mfilt1.alionscience.com) (192.104.146.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 09 Nov 2019 01:15:56 +0000 Received: from mfilt1.alionscience.com (127.0.0.1) id hoo9ko0171sf; Fri, 8 Nov 2019 20:15:54 -0500 (envelope-from ) Received: from noc-cas1.alionscience.com ([205.167.170.4]) by mfilt1.alionscience.com ([192.104.146.193]) (SonicWall 10.0.1.1213) with ESMTP id o201911090115540104951-74; Fri, 08 Nov 2019 20:15:54 -0500 Received: from NOC-MBX07.alionscience.com (172.20.3.236) by NOC-MBX07.alionscience.com (172.20.3.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Fri, 8 Nov 2019 20:15:53 -0500 Received: from NOC-MBX07.alionscience.com ([fe80::cd73:84f:ff0b:b766]) by NOC-MBX07.alionscience.com ([fe80::cd73:84f:ff0b:b766%6]) with mapi id 15.01.1591.017; Fri, 8 Nov 2019 20:15:53 -0500 From: "Smith-Rowland, Edward M" To: "libstdc++@gcc.gnu.org" , "jwakely@redhat.com" CC: "gcc-patches@gcc.gnu.org" Subject: Implement the part of C++20 p1032 Misc constexpr bits. Date: Sat, 9 Nov 2019 01:15:53 +0000 Message-ID: MIME-Version: 1.0 X-Mlf-DSE-Version: 5813 X-Mlf-Rules-Version: s20191106221030; ds20171117204456; di20191025164238; ri20160318003319; fs20191107232316 X-Mlf-Smartnet-Version: 20191105220248 X-Mlf-Version: 10.0.1.1213 X-Mlf-License: BSVKCAP____ X-Mlf-UniqueId: o201911090115540104951 I'm going to implement p1032 in pieces. It *is* miscellaneous after all ;-). Tested on x96_64-linux? OK? Index: include/std/array =================================================================== --- include/std/array (revision 277944) +++ include/std/array (working copy) @@ -112,11 +112,11 @@ // No explicit construct/copy/destroy for aggregate type. // DR 776. - void + _GLIBCXX20_CONSTEXPR void fill(const value_type& __u) { std::fill_n(begin(), size(), __u); } - void + _GLIBCXX20_CONSTEXPR void swap(array& __other) noexcept(_AT_Type::_Is_nothrow_swappable::value) { std::swap_ranges(begin(), end(), __other.begin()); } @@ -288,6 +288,7 @@ // Specialized algorithms. template + _GLIBCXX20_CONSTEXPR inline #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 // Constrained free swap overload, see p0185r1 @@ -295,7 +296,6 @@ _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_Is_swappable::value >::type #else - _GLIBCXX20_CONSTEXPR void #endif swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two) Index: testsuite/23_containers/array/requirements/constexpr_fill.cc =================================================================== --- testsuite/23_containers/array/requirements/constexpr_fill.cc (nonexistent) +++ testsuite/23_containers/array/requirements/constexpr_fill.cc (working copy) @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } +// +// Copyright (C) 2019 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 +// . + +#include + +constexpr bool +test_array() +{ + auto ok = true; + + std::array fa{}; + fa.fill(3.333f); + + ok = ok && (fa[0] == fa[2]); + + return ok; +} + +static_assert(test_array()); Index: testsuite/23_containers/array/requirements/constexpr_swap.cc =================================================================== --- testsuite/23_containers/array/requirements/constexpr_swap.cc (nonexistent) +++ testsuite/23_containers/array/requirements/constexpr_swap.cc (working copy) @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } +// +// Copyright (C) 2019 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 +// . + +#include + +constexpr bool +test_array() +{ + auto ok = true; + + std::array fa{{1.1f, 2.2f, 3.3f}}; + + std::array fb{{4.4f, 5.5f, 6.6f}}; + + fb.swap(fa); + + ok = ok && (fa[0] == 4.4f); + + std::swap(fa, fb); + + ok = ok && (fa[0] == 1.1f); + + return ok; +} + +static_assert(test_array());