aboutsummaryrefslogtreecommitdiff
path: root/.gitignore
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2022-07-21 21:55:37 +0100
committerPedro Alves <pedro@palves.net>2022-07-22 14:18:49 +0100
commit37c2487312d2997bed16343f642ecb5e83bac979 (patch)
tree29d0d11be9ee7eff3e28246a14758db1a30cc758 /.gitignore
parent6577f365ebdee7dda71cb996efa29d3714cbccd0 (diff)
downloadfsf-binutils-gdb-users/palves/make_function_view.zip
fsf-binutils-gdb-users/palves/make_function_view.tar.gz
fsf-binutils-gdb-users/palves/make_function_view.tar.bz2
Introduce gdb::make_function_viewusers/palves/make_function_view
This adds gdb::make_function_view, which lets you create a function view from a callable without specifying the function_view's template parameter. For example, this: auto lambda = [&] (int) { ... }; auto fv = gdb::make_function_view (lambda); instead of: auto lambda = [&] (int) { ... }; gdb::function_view<void (int)> fv = lambda; It is particularly useful if you have a template function with an optional function_view parameter, whose type depends on the function's template parameters. Like: template<typename T> void my_function (T v, gdb::function_view<void(T)> callback = nullptr); For such a function, the type of the callback argument you pass must already be a function_view. I.e., this wouldn't compile: auto lambda = [&] (int) { ... }; my_function (1, lambda); With gdb::make_function_view, you can write the call like so: auto lambda = [&] (int) { ... }; my_function (1, gdb::make_function_view (lambda)); Unit tests included. Tested by building with GCC 9.4, Clang 10, and GCC 4.8.5, on x86_64 GNU/Linux, and running the unit tests. Change-Id: I5c4b3b4455ed6f0d8878cf1be189bea3ee63f626
Diffstat (limited to '.gitignore')
0 files changed, 0 insertions, 0 deletions