From d4b798c609965729bd1ae3a5385f43440999ef77 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 9 Jan 2023 21:10:45 -0700 Subject: [PATCH] Provide overloads of make_array_view() for std::array. --- include/deal.II/base/array_view.h | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) 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 -- 2.39.5