From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74337 invoked by alias); 22 Feb 2017 22:12:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 74325 invoked by uid 89); 22 Feb 2017 22:12:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy= X-HELO: mail-wr0-f194.google.com Received: from mail-wr0-f194.google.com (HELO mail-wr0-f194.google.com) (209.85.128.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Feb 2017 22:12:06 +0000 Received: by mail-wr0-f194.google.com with SMTP id q39so2018078wrb.2 for ; Wed, 22 Feb 2017 14:12:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=x7XPEzjhZ6lHny5S1aEi09EZFY/vFmwp50jaXiQatpk=; b=O/kndWiGHAWH3f2AYZ12SK3LV37p+fRzEs7/QsxS6I/ByX7HU3eSkK2MJ5GA/N+uO4 GQepHUnJDhI6T1K1et5Lf1xqs+jqXlBV4UQVj+crLjueGOlHxq0jAoHbRNOLxBa0Up4E ddMSfdkNpvm6ipukFol+yu8dhhi7qWMWWdeyzbJ+e40KpQAb7hsEV9hL4qvYrZsKcn8F wmca6uDGuz6F8dnD+JlbWwxnoezOhSR0Kkom3B655xygOLc5x/Oq0pifVAYY7b68y2kE w9fH0rYYj3u6th+pkeCbyIrs98kX6w0FxdlilC1lFDSbHrR4z8ZYAQjmwctXP250uudG gi2Q== X-Gm-Message-State: AMke39l5wOcEYNu4Y+kWXYdT8iu2j8PwHAF7jRofUZYuD7LmR+cwMXtFhpwo0F2wYa+MOQ== X-Received: by 10.223.167.71 with SMTP id e7mr26918797wrd.154.1487801524969; Wed, 22 Feb 2017 14:12:04 -0800 (PST) Received: from localhost ([2a02:c7d:8e39:c00:907d:dd4f:8d3c:1550]) by smtp.gmail.com with ESMTPSA id i189sm4189002wmg.7.2017.02.22.14.12.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Feb 2017 14:12:04 -0800 (PST) Date: Wed, 22 Feb 2017 22:12:00 -0000 From: Yao Qi To: Pedro Alves Cc: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH v1.1 1/3] Introduce gdb::function_view Message-ID: <20170222221158.hqfnyyvyqqxetygk@localhost> References: <1487775033-32699-1-git-send-email-palves@redhat.com> <1487775033-32699-2-git-send-email-palves@redhat.com> <8636f39b5e1e2cbdeabbf8dfd999e709@polymtl.ca> <4c8528d8-0115-3bf3-0a16-42f44be580a9@redhat.com> <20baebcd-0f6a-89ca-ef34-503795171d43@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20baebcd-0f6a-89ca-ef34-503795171d43@redhat.com> User-Agent: NeoMutt/20161104 (1.7.1) X-IsSubscribed: yes X-SW-Source: 2017-02/txt/msg00611.txt.bz2 On 17-02-22 17:49:22, Pedro Alves wrote: > On 02/22/2017 05:40 PM, Pedro Alves wrote: > > > I'll send the updated (squashed) patch as a reply. > > Here is is. Thanks for the quick review! > > From 997f0e94cbd2d1cdb4bf7612df1de72ce1a6eb56 Mon Sep 17 00:00:00 2001 > From: Pedro Alves > Date: Wed, 22 Feb 2017 17:43:09 +0000 > Subject: [PATCH] Introduce gdb::function_view > > This commit adds new function_view type. This type holds a a Double "a" at the end. > non-owning reference to a callable. It is meant to be used as > callback type of functions, instead of using C-style pair of function > pointer and 'void *data' arguments. function_view allows passing > references to stateful function objects / lambdas w/ captures as > callbacks efficiently, while function pointer + 'void *' does not. > > See the intro in the new function-view.h header for more. > > Unit tests included. I added a new gdb/unittests/ subdir this time, > instead of putting the tests under gdb/. If this is agreed to be a > good idea, some of the current selftests that exercise gdb/common/ > things but live in gdb/ could move here (e.g., gdb/utils-selftests.c). I wanted to add gdb/unittests for a while, but didn't have a chance to do so. Yes, it is a good idea to me. How is GDB unit tests, like disasm-selftests.c? Do you want to move it to gdb/unittests/? > + C++11 gave us std::function as type-erased wrapper around arbitrary > + callables, however, std::function is not an ideal fit for transient > + callbacks such as the use case above. For this use case, which is > + quite pervasive, a function_view is a better choice, because while > + while function_view is light and does not require any heap Double "while"s. > +namespace gdb { > + This is a new namespace in gdb source. What is the rule of using this namespace? -- Yao