From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 119EF3858D33; Wed, 16 Aug 2023 17:30:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 119EF3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-99bfcf4c814so903524766b.0; Wed, 16 Aug 2023 10:30:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692207029; x=1692811829; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OXz4CcmpTvvqTKPMV6kjz6SKPPNPE5NZwlPaBqzGyR0=; b=iDvQxtpr2WIu18bEXZf9SAdImffvO/vc2oLCUyNTkN2LMhGI0Aq7N0mKucWz1BjHiE eJoMCGfLgJOLhQ/jVfiM57dH3d1O8my/daniDtOt8NT7YmiT7zMJDpXAbJM/mLHHKLcX QvQT0m25hXQFEOJUHMr+plrhigOVo0CtSXX3vBPma/iJRIWFgGZyoryjqgzME97TDCEu lGzM/S1+8/NBC3DSnmfdMOKALT8boVNUhaqrTXObbMjiF/GsPIZELdJ276qZFDONVsVA 9rlgHOTqzvMSofGETcrMBSItga7S+QG1kt7dGqCiG2kCPS1gasjsr1ZVUe6GjVeZ7WYn 7Rtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692207029; x=1692811829; 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=OXz4CcmpTvvqTKPMV6kjz6SKPPNPE5NZwlPaBqzGyR0=; b=TZ07OhTmjAupsA8CLK4qgs4VPyRou91XQ14BNHPDpf397lN1L6Cg24seA2BbKsvdID /9tG5WqBqtsxr8iJY/gswB7d1UZajD0kFcQ81tDabIO2xPwkfH5wpAeFPsI/TeIwXDfw jnMic6hZ+GP2WmZx/rDptw4fDX36h54+3usiRN3DjCt85Mg2W54YpJxoIqiVoEWSxNXG 9ZCSgXu3W5hlXIRo86e6OOpakR3QAwlJAo4eFt9nLDOxyrzrMblVckWWTKbXWaM8J5oS OS055de2uhbmYsvPqCHXGovt5yqNMUa3YOtj+GjCO+z54g8hhUptwTFUp3Ofgb8cUwMa +3Xw== X-Gm-Message-State: AOJu0Yy+iEJfLNP6eYWDx6TG7Nyavuiuhz9JST26+YaTt6FN3hsFDUTj E6HaZOIfZUgn6UG6QNrGCXDyVAzFKUehei8Og+o= X-Google-Smtp-Source: AGHT+IHlS8NDCeY0g2wDXOyfFAXU0lhuaRTEQZHohMBHsaquVd10qzmILSvyvab5SLHivCVHYE+lKbp4fn5PC4zwvHA= X-Received: by 2002:a17:906:9be9:b0:993:dd1d:8251 with SMTP id de41-20020a1709069be900b00993dd1d8251mr2226999ejc.28.1692207028519; Wed, 16 Aug 2023 10:30:28 -0700 (PDT) MIME-Version: 1.0 References: <20230424162347.104093-1-ppalka@redhat.com> In-Reply-To: From: Jonathan Wakely Date: Wed, 16 Aug 2023 18:30:18 +0100 Message-ID: Subject: Re: [PATCH] libstdc++: Make __max_size_type and __max_diff_type structural To: Patrick Palka Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham 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 Wed, 16 Aug 2023 at 17:07, Patrick Palka via Libstdc++ wrote: > > 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 I'm not sure about this one. I am pretty sure it's not required, and I'm not sure it's needed. Do we have a use for it ourselves? Users shouldn't be using this type directly, or relying on properties that the standard doesn't specify, so I don't think they should be using it as a structural type. > > > > > 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/i= nclude/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_B= IT__; > > - 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/= libstdc++-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 use= d > > +// 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 > > >