aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.h
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-09-04 17:10:12 +0100
committerPedro Alves <palves@redhat.com>2017-09-04 17:10:12 +0100
commit7c44b49cb63662b76c6301fdc8e022d7aca655bf (patch)
tree0d03dd6a993fe6b5b1b430b467905820256b9892 /gdb/symtab.h
parente439fa140afdaedb28a97acaa2b0432b884d8a91 (diff)
downloadgdb-7c44b49cb63662b76c6301fdc8e022d7aca655bf.zip
gdb-7c44b49cb63662b76c6301fdc8e022d7aca655bf.tar.gz
gdb-7c44b49cb63662b76c6301fdc8e022d7aca655bf.tar.bz2
Introduce gdb::array_view
An array_view is an abstraction that provides a non-owning view over a sequence of contiguous objects. A way to put it is that array_view is to std::vector (and std::array and built-in arrays with rank==1) like std::string_view is to std::string. The main intent of array_view is to use it as function input parameter type, making it possible to pass in any sequence of contiguous objects, irrespective of whether the objects live on the stack or heap and what actual container owns them. Implicit construction from the element type is supported too, making it easy to call functions that expect an array of elements when you only have one element (usually on the stack). For example: struct A { .... }; void function (gdb::array_view<A> as); std::vector<A> std_vec = ...; std::array<A, N> std_array = ...; A array[] = {...}; A elem; function (std_vec); function (std_array); function (array); function (elem); Views can be either mutable or const. A const view is simply created by specifying a const T as array_view template parameter, in which case operator[] of non-const array_view objects ends up returning const references. (Making the array_view itself const is analogous to making a pointer itself be const. I.e., disables re-seating the view/pointer.) Normally functions will pass around array_views by value. Uses of gdb::array_view (other than the ones in the unit tests) will be added in a follow up patch. gdb/ChangeLog 2017-09-04 Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add unittests/array-view-selftests.c. (SUBDIR_UNITTESTS_OBS): Add array-view-selftests.o. * common/array-view.h: New file. * unittests/array-view-selftests.c: New file.
Diffstat (limited to 'gdb/symtab.h')
0 files changed, 0 insertions, 0 deletions