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.133.124]) by sourceware.org (Postfix) with ESMTPS id 92D233858C5E for ; Thu, 23 Feb 2023 17:53:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 92D233858C5E 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=1677174812; 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=GIxe+AgrpB2C5vsA5zNkxp4FR5vxlgsF+a6fyF85rgQ=; b=fuPiErZq0UXqZER/YA+dqpwWPnzRaQkFCdsLgDU+gblezzImLI4g1vOBCDE57uCmmFWuR9 gEKx41ZSaYY78uy2tpO+H42mxyR5joi/GqO9E4qR24mRLuqaYdQX/BkVCc5Oss+iy1dj9h LE89KSQUIee1MjtfCJF00pc5p0/4nwY= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-184-S01HgSUMNOq28y0Jqu8mpQ-1; Thu, 23 Feb 2023 12:53:31 -0500 X-MC-Unique: S01HgSUMNOq28y0Jqu8mpQ-1 Received: by mail-lf1-f71.google.com with SMTP id x22-20020a056512047600b004db2a1fed99so3312703lfd.15 for ; Thu, 23 Feb 2023 09:53:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=GIxe+AgrpB2C5vsA5zNkxp4FR5vxlgsF+a6fyF85rgQ=; b=7C0M+I0zgj7Vm7kXHUa+2QIjbZl3/o7+Kg6IeG6BMgxfOoMBvBWTpeJgZETs5RTEkA AKhsdoUpos8GhLlAhq2AXRjQe6Ab3v9ayfylq+r3q68KOuhrKkySRBOl7tA8fUTEvO8R 5ZnEeC1HG3C5WE6Vulk7OCnGTJtVqaaGGR+v9VsWUxt6Khj68nRHPttXVy8LTHC6nW4H YMIZ977VRppGbWjUHd6sS4Vy1xLCxW7ex45At4Mprx1EpWDJeE0aRyn1GZwmjLZDkGjA 2A2pbhsWw4xiGh6QYqwO8hYqfZmWxSXuADd0nGMSIlX0drYuWuGQAB9mXoHue6Sho+Y8 76dw== X-Gm-Message-State: AO0yUKU79azg2lTCXMNlHtFsw4d3gNAss9au8OGgNyfP7/PqT0JOs3Pg ETMHcsNRzCXRNQBj+Izp8ShTHMWPT/4wFHcGXFtl2PtcYuyBLdR1cr0zQY22RFICMnwyg8d+erZ +oSDYZKejg5mwanizKjtXl1Ce+n1uOrQ= X-Received: by 2002:a05:651c:382:b0:293:2192:16ab with SMTP id e2-20020a05651c038200b00293219216abmr3866416ljp.7.1677174809639; Thu, 23 Feb 2023 09:53:29 -0800 (PST) X-Google-Smtp-Source: AK7set8xntprCe+plRriJ6S9Hj3AUQnnuU41UHXa6ev+C/9Gs1+DEONVwgZp8m/ltdTGTYMo4fRaIE2jpfoXs2BSU+Y= X-Received: by 2002:a05:651c:382:b0:293:2192:16ab with SMTP id e2-20020a05651c038200b00293219216abmr3866413ljp.7.1677174809299; Thu, 23 Feb 2023 09:53:29 -0800 (PST) MIME-Version: 1.0 References: <20230223173741.532305-1-jwakely@redhat.com> In-Reply-To: From: Jonathan Wakely Date: Thu, 23 Feb 2023 17:53:17 +0000 Message-ID: Subject: Re: [PATCH] libstdc++: Add Doxygen comment for string::resize_and_overwite To: =?UTF-8?Q?Daniel_Kr=C3=BCgler?= Cc: libstdc++@gcc.gnu.org, gcc-patches@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.2 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_H2,SPF_HELO_NONE,SPF_NONE,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 Thu, 23 Feb 2023 at 17:42, Daniel Kr=C3=BCgler wrote: > > Am Do., 23. Feb. 2023 um 18:38 Uhr schrieb Jonathan Wakely via > Libstdc++ : > > > > Reviews of the resize_and_overwite description welcome. I've tried to > > strike a balance between pedantic precision and user-friendliness. > > > > -- >8 -- > > > > This is a complicated API that should be clearly documented. > > > > Also improve the comment on basic_ios::_M_setstate. > > > > libstdc++-v3/ChangeLog: > > > > * include/bits/basic_ios.h (basic_ios::_M_setstate): Add > > caveat to comment. > > * include/bits/basic_string.h (resize_and_overwrite): Add > > doxygen comment. > > --- > > libstdc++-v3/include/bits/basic_ios.h | 2 +- > > libstdc++-v3/include/bits/basic_string.h | 28 ++++++++++++++++++++++++ > > 2 files changed, 29 insertions(+), 1 deletion(-) > > > > diff --git a/libstdc++-v3/include/bits/basic_ios.h b/libstdc++-v3/inclu= de/bits/basic_ios.h > > index e0667b7d049..d0a4e7d3dfd 100644 > > --- a/libstdc++-v3/include/bits/basic_ios.h > > +++ b/libstdc++-v3/include/bits/basic_ios.h > > @@ -159,7 +159,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > > > // Flip the internal state on for the proper state bits, then > > // rethrows the propagated exception if bit also set in > > - // exceptions(). > > + // exceptions(). Must only be called within a catch handler. > > void > > _M_setstate(iostate __state) > > { > > diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/in= clude/bits/basic_string.h > > index c81dc0d425a..1abac655fd1 100644 > > --- a/libstdc++-v3/include/bits/basic_string.h > > +++ b/libstdc++-v3/include/bits/basic_string.h > > @@ -1117,6 +1117,34 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 > > > > #if __cplusplus > 202002L > > #define __cpp_lib_string_resize_and_overwrite 202110L > > + /** Resize the string and call a function to fill it. > > + * > > + * @param __n The maximum size requested. > > + * @param __op A callable object that writes characters to the = string. > > + * > > + * This is a low-level function that is easy to misuse, be caref= ul. > > + * > > + * Calling `str.resize_and_overwrite(n, op)` will reserve at lea= st `n` > > + * characters in `str`, evaluate `n2 =3D std::move(op)(str.data(= ), n)`, > > + * and finally set the string length to `n2` (adding a null term= inator > > + * at the end). The function object `op` is allowed to write to = the > > + * extra capacity added by the initial reserve operation, which = is not > > + * allowed if you just call `str.reserve(n)` yourself. > > + * > > + * This can be used to efficiently fill a `string` buffer withou= t the > > + * overhead of zero-initializing characters that will be overwri= tten > > + * anyway. > > + * > > + * The callable `op` not access the string directly (only throug= h the > > Did you mean "The callable `op` must not access the string > directly" instead? I did, thanks! Fixed locally.