From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 6C0953857715 for ; Wed, 16 Aug 2023 16:06:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6C0953857715 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692202006; 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=sTXumFpBfoCeBG79W1MXtgHhIshp7bbkOXsPvLO/DOc=; b=aGgVFHwo+X+SdWz73WiFyO6F85w9ZNPPPycNrK6B0Hg/cUS5iCmvvhy6m9GeeIhoGLLvFY 3bgPw3vlouHu1MB32WBYnGRlwWRlKETtIEUUSmaYqTVWbNUA9ibnT34+P9kn5Cibi3aq7q rXnJHh7gIcVINtAfdZQTHx5yFix2IGM= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-581-OLytWXoVOWGt-To3i9B2fQ-1; Wed, 16 Aug 2023 12:06:42 -0400 X-MC-Unique: OLytWXoVOWGt-To3i9B2fQ-1 Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2b9aa4db031so68460401fa.3 for ; Wed, 16 Aug 2023 09:06:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692202001; x=1692806801; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sTXumFpBfoCeBG79W1MXtgHhIshp7bbkOXsPvLO/DOc=; b=jIvgzqZsETEq0PvDOskw1UFYNehvHCWvRDMRaCnW9JAqdX3WqmcTIz3u16V0rH4s9P SyKNvr6fu7Ui6GgUD6Lo84RX36Ovgv+ZWAr8i6O1SuKB3siEOrgorvwih+6GqR5u0Rfa Fcn/GVWXeZMAVllb78y48YmKtrzlgZxqW52g6p8MiZKzJBEf0bwyUnp8MIuNG3TiE3/x nNG/fludeKuZgh2nS9IqlIebaoazyCbyKW+YrN8CTOGCAbNmuTwdgZmbeTncpoCgTyf9 9sbsMDyj+UqWoSqYWNav/C4rF9ir1UkerBsF4y27XxJ9haijVurdpZPM/xU1UcbUx4iV wsyQ== X-Gm-Message-State: AOJu0Yxc6eHXi45sh6iF7hOsG1e/nSY1PC7tgmKbuXggePf1Qeyaj3u7 tYKaG5n1mKAhvPPnhtWevgIhOe57tEq4kFc1QW0IdyRrfyVOSmgzezentW/nBpe51YKdy8a/PLH ueih4RW4jzfUbBRYprzj5F4jS1Bp0o9mwvHhNpgJm4g== X-Received: by 2002:a2e:9256:0:b0:2bb:99fa:1772 with SMTP id v22-20020a2e9256000000b002bb99fa1772mr1427569ljg.49.1692202000838; Wed, 16 Aug 2023 09:06:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHUDNa66J1ScMFTHWdLw/npXY13bv1lqyef+RuWOy55P9+g7INtOZJjzbG1Klzxnb5PQ9P18ys3775KZueQ/Fg= X-Received: by 2002:a2e:9256:0:b0:2bb:99fa:1772 with SMTP id v22-20020a2e9256000000b002bb99fa1772mr1427557ljg.49.1692202000546; Wed, 16 Aug 2023 09:06:40 -0700 (PDT) MIME-Version: 1.0 References: <20230424162347.104093-1-ppalka@redhat.com> In-Reply-To: <20230424162347.104093-1-ppalka@redhat.com> From: Patrick Palka Date: Wed, 16 Aug 2023 12:06:29 -0400 Message-ID: Subject: Re: [PATCH] libstdc++: Make __max_size_type and __max_diff_type structural To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Apr 24, 2023 at 12:23=E2=80=AFPM Patrick Palka = wrote: > > This patch makes these integer-class type structural types by changing > their private data members into public ones, which allows them to be > used as NTTP types. I'm not sure if this is required by the standard > but it seems handy. > > Tested on x86_64-pc-linux-gnu, does this look OK for trunk? Ping > > libstdc++-v3/ChangeLog: > > * include/bits/max_size_type.h (__max_size_type::_M_val): Make > public instead of private. > (__max_size_type::_M_msb): Likewise. > (__max_diff_type::_M_rep): Likewise. > * testsuite/std/ranges/iota/max_size_type.cc: Verify > __max_diff_type and __max_size_type are structural. > --- > libstdc++-v3/include/bits/max_size_type.h | 4 ++-- > libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc | 7 +++++++ > 2 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/libstdc++-v3/include/bits/max_size_type.h b/libstdc++-v3/inc= lude/bits/max_size_type.h > index 4796135d073..d6705bbe4c8 100644 > --- a/libstdc++-v3/include/bits/max_size_type.h > +++ b/libstdc++-v3/include/bits/max_size_type.h > @@ -423,10 +423,11 @@ namespace ranges > using __rep =3D unsigned long long; > #endif > static constexpr size_t _S_rep_bits =3D sizeof(__rep) * __CHAR_BIT= __; > - private: > + > __rep _M_val =3D 0; > unsigned _M_msb:1 =3D 0; > > + private: > constexpr explicit > __max_size_type(__rep __val, int __msb) noexcept > : _M_val(__val), _M_msb(__msb) > @@ -750,7 +751,6 @@ namespace ranges > { return !(__l < __r); } > #endif > > - private: > __max_size_type _M_rep =3D 0; > > friend class __max_size_type; > diff --git a/libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc b/li= bstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc > index 985acd5a803..9afd05d5acf 100644 > --- a/libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc > +++ b/libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc > @@ -400,6 +400,13 @@ static_assert(max_diff_t(max_size_t(1) > << (numeric_limits::digits-1)) > =3D=3D numeric_limits::min()); > > +// Verify that the types are structural types and can therefore be used > +// as NTTP types. > +template struct Su { static_assert(V*V =3D=3D V+132); }; > +template struct Ss { static_assert(V*V =3D=3D V+132); }; > +template struct Su<12>; > +template struct Ss<12>; > + > int > main() > { > -- > 2.40.0.374.g7580f92ffa >