From: Wolfgang Bangerth Date: Tue, 10 Jan 2023 04:10:45 +0000 (-0700) Subject: Provide overloads of make_array_view() for std::array. X-Git-Tag: v9.5.0-rc1~667^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4b798c609965729bd1ae3a5385f43440999ef77;p=dealii.git Provide overloads of make_array_view() for std::array. --- diff --git a/include/deal.II/base/array_view.h b/include/deal.II/base/array_view.h index 5d603c3018..c1bae3177b 100644 --- a/include/deal.II/base/array_view.h +++ b/include/deal.II/base/array_view.h @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -1065,6 +1066,52 @@ make_array_view(const std::vector &vector, +/** + * Create a view to an entire std::array object. This is equivalent to + * initializing an ArrayView object with a pointer to the first element and + * the size of the given argument. + * + * This function is used for non-@p const references to objects of array + * type. Such objects contain elements that can be written to. Consequently, + * the return type of this function is a view to a set of writable objects. + * + * @param[in] array The std::array object for which we want to have an array + * view object. The array view corresponds to the entire array. + * + * @relatesalso ArrayView + */ +template +inline ArrayView +make_array_view(std::array &array) +{ + return ArrayView(array); +} + + + +/** + * Create a view to an entire std::array object. This is equivalent to + * initializing an ArrayView object with a pointer to the first element and + * the size of the given argument. + * + * This function is used for @p const references to objects of array type + * because they contain immutable elements. Consequently, the return type of + * this function is a view to a set of @p const objects. + * + * @param[in] array The std::array object for which we want to have an array + * view object. The array view corresponds to the entire array. + * + * @relatesalso ArrayView + */ +template +inline ArrayView +make_array_view(const std::array &array) +{ + return ArrayView(array); +} + + + /** * Create a view to an entire row of a Table<2> object. This is equivalent to * initializing an ArrayView object with a pointer to the first element of the