From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KUG9M5yPomoohzwAWB0awg (envelope-from ) for ; Thu, 10 Sep 2026 07:08:12 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dvYVFQux; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id CE52A1E09E; Thu, 10 Sep 2026 07:08:12 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id F1C691E091 for ; Thu, 10 Sep 2026 07:08:11 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BA5BF4B99F79 for ; Thu, 10 Sep 2026 11:08:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA5BF4B99F79 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dvYVFQux Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 584DF4B9DB4F for ; Thu, 10 Sep 2026 11:07:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 584DF4B9DB4F Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 584DF4B9DB4F Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789038465; cv=none; b=Mo7Y04F2wfdUHf2MKggziyYgTQ+DUFqNHKvBAsoI3fjW7jfP5AqZl4Cg5MPMqELON5sAbvl3gCPAOxrR7CH66ebVV2qZf/m/I6WyMnvgP7GU8c/lu2QK8/1MK0ZnxYuOAMP9y1Elpr5Lfj7FFDyT2aDpSs2bTBq89b9qRf/fJJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789038465; c=relaxed/simple; bh=eEksfU4PKKNLeatTuWdeBiPP+n7Y6VOM/XFFVY7R5oQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=eYiEx2/Ru1zU5Kwgq5ebXDlKrkrZRWzcnA1j7fH7UICL4WT0Ub9czH5v9NUYolfr0b3s8McU1shvm2EnaP2ntHyVKL085BKXjdDOwOb33JW0YaNEHvtpnBZa2QGJh2R45AWq2yyy73JUqlgvwodHbNaWoyGu7npWzHyBC2DtXro= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dvYVFQux DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 584DF4B9DB4F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789038464; 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: in-reply-to:in-reply-to:references:references; bh=uYi39aDR6AMV/Zqu6iLr5RuDdU2j6Nfg/xmrodaMwaI=; b=dvYVFQuxsJk3lanpgWZUOhaHiihb/P4vl9ze1g8wMHcGPEhPX3RsQhFOSMyCYdIKkz4TNK zB8MyzabgzMLWCjrTdAW0kjzF6/ZiJId4RCX84htQxeTKI0Zl3FKZeygylmQI5Riot/HR0 kvcTPnsUpgNlpShFDIFfCyZoOs1mV3g= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-379-qCcCJHgkN_OwmkXzKDJ2wg-1; Thu, 10 Sep 2026 07:07:42 -0400 X-MC-Unique: qCcCJHgkN_OwmkXzKDJ2wg-1 X-Mimecast-MFC-AGG-ID: qCcCJHgkN_OwmkXzKDJ2wg_1789038461 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49cc954a3edso53985755e9.2 for ; Thu, 10 Sep 2026 04:07:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789038461; x=1789643261; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=uYi39aDR6AMV/Zqu6iLr5RuDdU2j6Nfg/xmrodaMwaI=; b=OZM3fkWWNU8CgJXspX3WUGKyOGSCVZWghuPV5MIqHp+LOwpxk99gpXYEkRKNYg1o3L bW2+SOMAEUiOTu4TH8maZSdmnvFTO32NZt9O7xNQiLDocqymgBY6hodtGWFYWioZGZt9 YlWO1FBWvw3qdh5+KCl9LwTeU7mr5wPH2/S5CEldVsZXwoMzUXbqmP528q1CaeIQUUBP XPNyBauD7mYumdgCt6CZyOmARLygoC1az6Kvp5J7DYwLraQAi0biMq3RmZh+xZwRdxvk AifPPW2xLbKvtfJbDuACfLPr4AdjiAfzK4LbiL2HXbcYKzmopI9UkkQ3vN7xKJjjXaJ/ d8+Q== X-Forwarded-Encrypted: i=1; AKwUvBy4RQI7xt1X+xZq3IJK5Q3oePxWNCoyMbSkaGL4npXJUvKXviW0s1otAx5C5T73Q9ZqBya707yK+76aFw==@sourceware.org X-Gm-Message-State: AFuF++mKu/zbuxKqjALJ4o23NtecFEiQcm9W7Vr7Q4XCnrb13RDK4Fbo f5+bVJKR0+PnEbQLunDeel6IUENqk3rDRLw2dEynFcrnllPQHAFsw9xtwUIhsVTzQk2KTZoX2ql /ou+ypM+GlYyz3EqCnIobRnh+HImjvNCq0e0VFX91Y4h5VzYVRJDcr2UZVDxf1oZfHFab9Ww= X-Gm-Gg: AYBFou04Ez/FwMU+t3AkMxEc/y+0WZSD9988Gk8p3FWn8gdntpmiL6Qr0N1ynZ+YsPf O5PXHcFbBmkc2WySWs8NQd77jdzt+3N+gbkEp+mFflyY90RbcZOuzZ/5S92K3UF2SJYJRIv0POJ 2DgI34Wfl+xAUAHix/Ml7ix9GBL3I+Jpe2WHvQifzz/KNbE5K++1hHnbpHF5zprqGkQlP/fKZ+4 Ne5i5dbqptgfrw8e2mabFn/2XVIvGhmRCMlA8fcW6bThspFyxWGsqYOSYumFgw6fyG3FqTxHCK9 IoejD09uupv5NLjEhWhZcTfGtHO6F0EKHU3UQTEUpmKbUkG3PLT47A4JdUd3YXKS5PMvyAO5dzN bUD2Sa4TWsSzyzZRQ X-Received: by 2002:a05:600c:628b:b0:49d:2856:fcf6 with SMTP id 5b1f17b1804b1-49d2856fe91mr36982865e9.15.1789038461233; Thu, 10 Sep 2026 04:07:41 -0700 (PDT) X-Received: by 2002:a05:600c:628b:b0:49d:2856:fcf6 with SMTP id 5b1f17b1804b1-49d2856fe91mr36982375e9.15.1789038460758; Thu, 10 Sep 2026 04:07:40 -0700 (PDT) Received: from localhost (59.6.93.209.dyn.plus.net. [209.93.6.59]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26bf2bb2sm60942265e9.7.2026.09.10.04.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 04:07:40 -0700 (PDT) From: Andrew Burgess To: Matthieu Longo , gdb-patches@sourceware.org Cc: Simon Marchi , Thiago Jung Bauermann , Luis Machado , Luis Machado , Christina Joos , Kevin Buettner , Matthieu Longo Subject: Re: [PATCH v2 2/6] gdb support: add gdb::ranges::replace algorithm In-Reply-To: <20260825100912.514232-3-matthieu.longo@arm.com> References: <20260825100912.514232-1-matthieu.longo@arm.com> <20260825100912.514232-3-matthieu.longo@arm.com> Date: Thu, 10 Sep 2026 12:07:39 +0100 Message-ID: <87ik4de550.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 9ET45F_H9N-f8fl4TP4ldaNExFeBEANdeZpFwOLcWzo_1789038461 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Matthieu Longo writes: > Provide a C++17-compatible replacement for the C++20 std::ranges::replace > algorithm, allowing callers to use a consistent interface until GDB > transitions to C++20. The helper should be removed once the C++ standard > library implementation become available. > > https://en.cppreference.com/cpp/algorithm/ranges/replace > --- > gdbsupport/array-view.h | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/gdbsupport/array-view.h b/gdbsupport/array-view.h > index 8431d7f5add..f9842ecff30 100644 > --- a/gdbsupport/array-view.h > +++ b/gdbsupport/array-view.h > @@ -225,6 +225,22 @@ void copy (gdb::array_view src, gdb::array_view dest) > std::copy_backward (src.begin (), src.end (), dest.end ()); > } > > +namespace ranges { > + > +/* Replace all occurrences of a value in the provided range. > + > + Note: this helper is a reimplementation of std::ranges::replace, only > + available from C++20 onwards, and consequently, should be replaced by > + std::ranges::replace once GDB switches to C++20. */ > + > +template > +void replace (Range r, const T &old_value, const T &new_value) Looking at the linked cppreference page, the C++20 functions take R as 'Range &&r'. Doesn't your versions create a copy of the range? This will work fine for non-owning ranges, like gdb::array_view, but will mean replace operates on a copy of the range for something like std::vector. Even if what you have above is intentional, I think this difference should be highlighted and explained. Also, as this isn't specifically tied to gdb::array_view, I wonder if this would be better put into a new file gdbsupport/ranges.h ? I don't think anything much is needed to create the new file other than just adding the file, so that should be pretty easy to do. Thanks, Andrew