From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 62mEDbDlX2o8ACIAWB0awg (envelope-from ) for ; Tue, 21 Jul 2026 17:33:36 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=WaSvuDv8; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 24A8D1E09E; Tue, 21 Jul 2026 17:33:36 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 36D011E033 for ; Tue, 21 Jul 2026 17:33:35 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D59794BA2E25 for ; Tue, 21 Jul 2026 21:33:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D59794BA2E25 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=WaSvuDv8 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 288954BA543C for ; Tue, 21 Jul 2026 21:33:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 288954BA543C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 288954BA543C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784669587; cv=none; b=iBelsI1tJ2vxy2Tl/e0E9CnjR4PkQb5Ry/cGoMasW9dWDu+lu3EavNITFm65NMKSDLaw289jiBB8Y1aGYKQiNewjHgdL2R4P2EZsB/S8Kn9W8SSbeEwKga2C6UiWqDLgPmUqt/val2uqFln6vQjfjJadXLd0DsFt7FSnMUd4bW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784669587; c=relaxed/simple; bh=vcPC0x1h8WQY4SnhXcVAufSReKmHWNu16tgVX5fZdj0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=PUYk45th0TuIgUB0hDJSc7KKwB6DTcLd0c9C2u65fGtpUnvd/Wy0YylBhFASdcUqHBPCVMfRaIH9ISkBeimNY+muxxlN4Cq0sKi2SKllzXV96b4UNCa23JPqphjrdvsqfBYK/JlWoMRKMYUgdYwMsDW683kAUjKg4ixrOml1eCc= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=WaSvuDv8 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 288954BA543C Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-49547fc63a0so24253355e9.2 for ; Tue, 21 Jul 2026 14:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784669586; x=1785274386; darn=sourceware.org; h=content-transfer-encoding:content-type:in-reply-to:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=rtuuL6fcnALtmmTNBW41q5xNblGeptJoKMQrBSE/cG4=; b=WaSvuDv8TUx18Y8zFuka2XRlnm6r9WDZzO5kbEgtlxjMnMapwmCi5zn1adekt2MsSt TLWpIhhd7v7EBqCg/iu/IwdebM5mUHtNscy9RD2/fWAuUUJfVpMLDnrWhwYJfNjISdeE cV9D89VQnEi2mImPtaQY7teDF6pc6JiG4eHy+EwhpnxEJVseo7Zo1/WNNCQQ/8wWcVwh InK7ArqAf+OnxvPY8doM/dR9/GXIsYy3JKF0r9drAJd7oWCGcNeeF01hN7w7UJSiUgbx RJNRkcKUBKLqpBXBDU8kaADlQn9ek3wVCu1e4TWxq7qUarbLlbjqlLUCEB26lIWDPJ/g WAnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784669586; x=1785274386; h=content-transfer-encoding:content-type:in-reply-to:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rtuuL6fcnALtmmTNBW41q5xNblGeptJoKMQrBSE/cG4=; b=DIFHn0nq+1zotgevI/meYW1Rll3ttZLBe37WDrRuzxXejMlueo53nTYN1FFJYRNx98 5KR1rnkF0u6luc/EzJ3Xy5ooR9ke2I44IJzUyfB/ugOrAydYJy0QCVL2SOmYXr+Ch9F1 Cj+F365fY4uq6T/kx61OgGICsfV0F1fT10M6gLgJJADgdbsB1OzysskVUjYyOQJ6wQ5r 8BQ/nG41rG4cKJeX5o2EJBlIUotZLu85iGyZ8745Wf/Ex9y4AMB0ENr9bf+oGGT1FjAp J9wdLa2v4dG/+6iko49PmFyDlfgI7PJkegZ1943mitYHVxBNe6fHJgdwLEu/hkeLH0X6 6OGg== X-Forwarded-Encrypted: i=1; AHgh+RoWTsUgt01Ezfww7hZIPYRRVyRe5U69LWhK4Ce/s0aV/ilroP+2KbpbiRuYBfrW6GbndDKe0qvKkfTngg==@sourceware.org X-Gm-Message-State: AOJu0YwKJgLvmufWvM2gEcMA6UhBQ6lgGYJd90h50gMn1mEIyKjL4eC7 r2l0wxQtRXkMvQIqmANIpgGtzpH5rnLjLzpuYZBmlGsiHpujke8jLSMg X-Gm-Gg: AR+sD11DerSD2SaIOj2cHWPavqHHTJAaYL890Q3k1FIOhKi8cLn9g/yFT4Yz0GQYRij s5j/7jJEEf8/p5NJykVF73m/9f8vjIH9ijKwLgtbR1sgajSa1lR33IbA5ZRMAO766I8pc4ePXFE 8VgZ/l4o8a3r6eO+qZHDpDCRkHqdXxQeNK+HFJ0Mz8yfzG17eBZerF5wmw4wX4Qg2BNA9JEsLal dKz04mNyoW+IgxLspwN0xx553W517xVPQWGWs07AOwQ20LJtrACOsHUYt4M42D9kBfzGJ5K4Hps hACtRpsNPrL1CfNHa1D0axGdRnVis9qma0kwv31eg7WOGHzltovF7jae3jX76PG08lwkM/P/Sqy cBWGjLyX95gqc3sRK35FrXjgk0KuxKLvJ6AzzCwvyRtk3wAggM/nFVW72ODl/pLdR7VEshwFCJV p3AMQ+IO2CavJbLtM= X-Received: by 2002:a05:600c:3107:b0:495:6b78:6f4 with SMTP id 5b1f17b1804b1-4956b78080fmr879675e9.8.1784669585866; Tue, 21 Jul 2026 14:33:05 -0700 (PDT) Received: from [192.168.0.38] ([86.12.216.189]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f69e5eff1sm32968150f8f.19.2026.07.21.14.33.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Jul 2026 14:33:05 -0700 (PDT) Message-ID: Date: Tue, 21 Jul 2026 22:33:04 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 04/10] gdb support: add gdb::replace algorithm for iterators and ranges Content-Language: en-US To: Matthieu Longo , gdb-patches@sourceware.org Cc: Luis Machado , Andrew Burgess , Yury Khrustalev , Pedro Alves , Tom Tromey References: <20260707154900.94542-1-matthieu.longo@arm.com> <20260707154900.94542-5-matthieu.longo@arm.com> From: Luis In-Reply-To: <20260707154900.94542-5-matthieu.longo@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 Drive-by review, and C++20 issues aside. On 07/07/2026 16:48, Matthieu Longo wrote: > Add a gdb::replace helper that mirrors the behavior of std::replace > for iterator pairs, together with a convenience overload accepting a > range. > > This provides a C++17-compatible replacement for the C++20 std::replace/ > std::ranges::replace algorithms, allowing callers to use a consistent > interface until GDB transitions to C++20. The helpers should be removed > once the C++ standard library implementations become available. > --- > gdbsupport/array-view.h | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/gdbsupport/array-view.h b/gdbsupport/array-view.h > index 8431d7f5add..61119d7a8e2 100644 > --- a/gdbsupport/array-view.h > +++ b/gdbsupport/array-view.h > @@ -225,6 +225,32 @@ void copy (gdb::array_view src, gdb::array_view dest) > std::copy_backward (src.begin (), src.end (), dest.end ()); > } > > +/* Replace all occurrences of a value in the provided range. > + > + Note: this helper is a reimplementation of std::replace, only available > + from C++20 onwards, and consequently, should be removed once we switch > + to C++20. */ > + > +template > +void replace (ForwardIt first, ForwardIt last, > + const T &old_value, const T &new_value) > +{ > + for (auto it = first; it != last; ++it) > + { > + if (*it == old_value) > + *it = new_value; > + } Formatting: Identation of the braces is off. > +} > + > +/* Replace all occurrences of a value in the provided array view. > + Note: from C++20 onwards, std::ranges::replace should be used instead. */ > + > +template > +void replace (Range r, const T &old_value, const T &new_value) > +{ > + replace (r.begin (), r.end (), old_value, new_value); > +} > + > /* Compare LHS and RHS for (deep) equality. That is, whether LHS and > RHS have the same sizes, and whether each pair of elements of LHS > and RHS at the same position compares equal. */