This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v1.1 1/3] Introduce gdb::function_view
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 <palves@redhat.com>
> 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