From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SdynOBWk9GkEBQkAWB0awg (envelope-from ) for ; Fri, 01 May 2026 09:01:09 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=oEkfL+Lq; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=OeG14Zo5; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=oEkfL+Lq; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=OeG14Zo5; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E3A9B1E0BA; Fri, 01 May 2026 09:01:09 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,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 702811E067 for ; Fri, 01 May 2026 09:01:08 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 242F446A9CDB for ; Fri, 1 May 2026 13:01:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 242F446A9CDB Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=oEkfL+Lq; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=OeG14Zo5; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=oEkfL+Lq; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=OeG14Zo5 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 52A184BA2E27 for ; Fri, 1 May 2026 13:00:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 52A184BA2E27 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 52A184BA2E27 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777640441; cv=none; b=E6mIJgJ18ZJgAOg+AvMa54XYFMOqc/i46HaQ6JWxe90+zn3ujjXkTqoWPzT7yBgW/G4sUvtXSDg8pnlFJOKGUUq7bm+9i1c+E4dkJFdof6Udd1905pgXm+DfTWzO8OdDUXGOtgql8TKuc7/cMY7n5FJFm7XEsatKQXcyjlRRYI0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777640441; c=relaxed/simple; bh=bRk6CwS1hXZV8gNJYn8wdXjXSERBRbgNcjULk31MS2s=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=xZriadfHx+OhQVFj1sjKPXpb0bXvvUghvjYbkDqoJFFUeMUPPSItJTIq/Ap3LfDTlxl/wDCIbWh4zGW9JvdlpIUGCk9/Kp5MUm/uW6nGflWZXyR+UnBOXtRhDL6ZZ0MB94C/eNOH/nUbJ7+xBfsP1BXMCNiycjBuJD48dCZogtY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52A184BA2E27 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3427B5BD6D; Fri, 1 May 2026 13:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1777640440; h=from:from:reply-to: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=sDTfR7qbTFcGDMZPTUIh7mJH3ViXIU8u3g3/t+PUTbA=; b=oEkfL+LqCZlF2jDhiExs2GIFzqeNxiAlpFxxFEkRH1Ceznry5JwvNsHgV/6e6zA2aBmLDY 241w6Y3i70057FUHMuozGcRad9zntxMe894DmhopN7669ZMrovRGRfJdJhdPO4tVU5SEk/ IklWwRGcKoHJVFJCLi2E6YP3xRiXhU8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1777640440; h=from:from:reply-to: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=sDTfR7qbTFcGDMZPTUIh7mJH3ViXIU8u3g3/t+PUTbA=; b=OeG14Zo5iDc3tVo5oq94RPIK5Dm3B7ue9YSGB3h+FeS+HkPSXr9JNsfSzqjpK8BcFFHR/0 9wtgpf6C+WvuoRDA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=oEkfL+Lq; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=OeG14Zo5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1777640440; h=from:from:reply-to: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=sDTfR7qbTFcGDMZPTUIh7mJH3ViXIU8u3g3/t+PUTbA=; b=oEkfL+LqCZlF2jDhiExs2GIFzqeNxiAlpFxxFEkRH1Ceznry5JwvNsHgV/6e6zA2aBmLDY 241w6Y3i70057FUHMuozGcRad9zntxMe894DmhopN7669ZMrovRGRfJdJhdPO4tVU5SEk/ IklWwRGcKoHJVFJCLi2E6YP3xRiXhU8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1777640440; h=from:from:reply-to: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=sDTfR7qbTFcGDMZPTUIh7mJH3ViXIU8u3g3/t+PUTbA=; b=OeG14Zo5iDc3tVo5oq94RPIK5Dm3B7ue9YSGB3h+FeS+HkPSXr9JNsfSzqjpK8BcFFHR/0 9wtgpf6C+WvuoRDA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1E495593B0; Fri, 1 May 2026 13:00:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id z+smBvij9GlvdgAAD6G6ig (envelope-from ); Fri, 01 May 2026 13:00:40 +0000 Message-ID: <183aeea4-50ce-4f24-9c09-f35ac03a08c0@suse.de> Date: Fri, 1 May 2026 15:00:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/7] [gdbsupport] Factor out base_next_iterator To: Tom Tromey Cc: gdb-patches@sourceware.org References: <20260423063530.1074175-1-tdevries@suse.de> <20260423063530.1074175-4-tdevries@suse.de> <87340kpbwx.fsf@tromey.com> Content-Language: en-US From: Tom de Vries In-Reply-To: <87340kpbwx.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:dkim,suse.de:email,sourceware.org:url]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 3427B5BD6D 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 On 4/24/26 6:21 PM, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries writes: > Tom> Instead, this patch factors out base_next_iterator, which contains all parts > Tom> not specific to "next", in other words, everything except the operator++. > > This looks pretty reasonable to me, though I wonder if it would be > improved using the CRTP idiom. > > It's not really needed but it could possibly be cleaner. > > https://en.cppreference.com/cpp/language/crtp > Thanks, I've done that in a v1 ( https://sourceware.org/pipermail/gdb-patches/2026-May/227066.html ). > Tom> + Instead of factoring out a base class, we could use something like this: > Tom> + > Tom> + template > Tom> + struct next_iterator > Tom> + { > Tom> + ... > Tom> + self_type &operator++ () > Tom> + { > Tom> + m_item = m_item->*F; > Tom> + return *this; > Tom> + } > Tom> + ... > Tom> + } > Tom> + > Tom> + but that has the drawback that it doesn't work with incomplete T. */ > > I am curious about this because I wonder how the current code could work > with an incomplete T -- since the code references T::next directly. > > Tom> - explicit next_iterator (T *item) > Tom> + explicit base_next_iterator (T *item) > Tom> : m_item (item) > Tom> { > Tom> } > > Tom> /* Create a one-past-the-end iterator. */ > Tom> - next_iterator () > Tom> + base_next_iterator () > Tom> : m_item (nullptr) > Tom> { > Tom> } > > These should probably be protected now because it doesn't make sense to > directly instantiate a base_next_iterator. > I did that initially, but Simon suggested importing the constructor from base_next_iterator, and that doesn't work if it's protected. > Tom> +template > Tom> +struct next_iterator : base_next_iterator { > > Brace placement. > Fixed. > Tom> + typedef next_iterator self_type; > Tom> + typedef T *value_type; > Tom> + typedef T *&reference; > Tom> + typedef T **pointer; > > I would have thought most of these would be inherited. > (I guess with CRTP this could all be in the base class) That's indeed what happened, these are gone now. Thanks, - Tom