From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id x0w+ERqs5GABSgAAWB0awg (envelope-from ) for ; Tue, 06 Jul 2021 15:16:42 -0400 Received: by simark.ca (Postfix, from userid 112) id 3898D1F1F4; Tue, 6 Jul 2021 15:16:42 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 898701E01F for ; Tue, 6 Jul 2021 15:16:41 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22F6338930EF for ; Tue, 6 Jul 2021 19:16:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22F6338930EF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1625599001; bh=GdV1ftFzvjmexNlFdRxkqh7pBpV4U7HkNgwqjhISvfQ=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=weuVxSEaCr9TgAYUgnXuy3tqB5HYqw8plD0oW2YTNoAi0yrodBjJ9001hTGq+vWke LcSXyfWzZVIxnwGVv8CEFuQvt5rXWZBvwqVplc8PDyYt4nnSygFM8uezT7LajE9A+V G0hxyQDoYww/k1c1zivxmE/bfCHBz9Z7sF6oJawY= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 27FFC3864858 for ; Tue, 6 Jul 2021 19:16:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 27FFC3864858 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 166JGDX0024117 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 6 Jul 2021 15:16:18 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 166JGDX0024117 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id AD4CF1E01F; Tue, 6 Jul 2021 15:16:13 -0400 (EDT) Subject: Re: [PATCH 01/11] gdb: introduce iterator_range, remove next_adapter To: Pedro Alves , gdb-patches@sourceware.org References: <20210622165704.2404007-1-simon.marchi@polymtl.ca> <20210622165704.2404007-2-simon.marchi@polymtl.ca> <95009c05-bc89-6ad1-682d-b3b5c07d0f45@palves.net> Message-ID: Date: Tue, 6 Jul 2021 15:16:13 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <95009c05-bc89-6ad1-682d-b3b5c07d0f45@palves.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 6 Jul 2021 19:16:14 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 2021-07-05 11:41 a.m., Pedro Alves wrote: > On 2021-06-22 5:56 p.m., Simon Marchi via Gdb-patches wrote: >> I was always a bit confused by next_adapter, because it kind of mixes >> the element type and the iterator type. In reality, it is not much more >> than a class that wraps two iterators (begin and end). However, it >> assumes that: >> >> - you can construct the begin iterator by passing a pointer to the >> first element of the iterable >> - you can default-construct iterator to make the end iterator >> >> I think that by generalizing it a little bit, we can re-use it at more >> places. >> >> Rename it to "iterator_range". I think it describes a bit better: it's >> a range made by wrapping a begin and end iterator. Move it to its own >> file, since it's not related to next_iterator anymore. >> >> iterator_range has two constructors. The variadic one, where arguments >> are forwarded to construct the underlying begin iterator. The end >> iterator is constructed through default construction. This is a >> generalization of what we have today. >> >> There is another constructor which receives already constructed begin >> and end iterators, useful if the end iterator can't be obtained by >> default-construction. Or, if you wanted to make a range that does not >> end at the end of the container, you could pass any iterator as the >> "end". >> >> This generalization allows removing some "range" classes, like >> all_inferiors_range. These classes existed only to pass some arguments >> when constructing the begin iterator. With iterator_range, those same >> arguments are passed to the iterator_range constructed and then >> forwarded to the constructed begin iterator. >> >> There is a small functional difference in how iterator_range works >> compared to next_adapter. next_adapter stored the pointer it received >> as argument and constructeur an iterator in the `begin` method. >> iterator_range constructs the begin iterator and stores it as a member. >> Its `begin` method returns a copy of that iterator. >> >> With just iterator_range, uses of next_adapter would be replaced >> with: >> >> using foo_iterator = next_iterator; >> using foo_range = iterator_range; >> >> However, I added a `next_range` wrapper as a direct replacement for >> next_adapter. IMO, next_range is a slightly better name than >> next_adapter. >> >> The rest of the changes are applications of this new class. > > LGTM. Thanks, I pushed it by itself, since it's useful on its own. Simon