@@ -1240,7 +1240,7 @@ NDARRAY_HOST_DEVICE auto transpose_impl(const Shape& shape, index_sequence<Extra
12401240 shape.template dim <DimIndices>()..., shape.template dim <sizeof ...(DimIndices) + Extras>()...);
12411241}
12421242
1243- } // namespace internal
1243+ } // namespace internal
12441244
12451245/* * Create a new shape using a list of `DimIndices...` to use as the
12461246 * dimensions of the shape. The new shape's i'th dimension will be the
@@ -1252,7 +1252,8 @@ NDARRAY_HOST_DEVICE auto transpose_impl(const Shape& shape, index_sequence<Extra
12521252 *
12531253 * Examples:
12541254 * - `transpose<2, 0, 1>(s) == make_shape(s.dim<2>(), s.dim<0>(), s.dim<1>())`
1255- * - `transpose<1, 0>(s) == make_shape(s.dim<1>(), s.dim<0>(), ...)` where ... is all dimensions after dimension 1. */
1255+ * - `transpose<1, 0>(s) == make_shape(s.dim<1>(), s.dim<0>(), ...)` where ... is all dimensions
1256+ * after dimension 1. */
12561257template <size_t ... DimIndices, class ... Dims,
12571258 class = internal::enable_if_permutation<sizeof ...(DimIndices), DimIndices...>>
12581259NDARRAY_HOST_DEVICE auto transpose (const shape<Dims...>& shape) {
@@ -1391,8 +1392,7 @@ NDARRAY_INLINE NDARRAY_HOST_DEVICE void for_each_value_in_order(
13911392
13921393// Scalar buffers are a special case. The enable_if here (and above) are a workaround for a bug in
13931394// old versions of GCC that causes this overload to be ambiguous.
1394- template <size_t D, class Fn , class ... Ptrs,
1395- std::enable_if_t <(D == -1 ), int > = 0 >
1395+ template <size_t D, class Fn , class ... Ptrs, std::enable_if_t <(D == -1 ), int > = 0 >
13961396NDARRAY_INLINE NDARRAY_HOST_DEVICE void for_each_value_in_order (
13971397 const std::tuple<>& extent, Fn&& fn, Ptrs... ptrs) {
13981398 fn (*std::get<0 >(ptrs)...);
@@ -1553,7 +1553,8 @@ NDARRAY_HOST_DEVICE auto make_compact(const Shape& s) {
15531553
15541554/* * A `shape` where all extents (and automatically computed compact strides) are constant. */
15551555template <index_t ... Extents>
1556- using fixed_dense_shape = decltype (make_shape_from_tuple(internal::make_compact_dims<1 >(dim<0 , Extents>()...)));
1556+ using fixed_dense_shape =
1557+ decltype (make_shape_from_tuple(internal::make_compact_dims<1 >(dim<0 , Extents>()...)));
15571558
15581559/* * Returns `true` if a shape `src` can be assigned to a shape of type
15591560 * `ShapeDst` without error. */
@@ -2870,6 +2871,13 @@ const_array_ref<U, Shape> reinterpret(const array<T, Shape, Alloc>& a) {
28702871 return reinterpret<const U>(a.cref ());
28712872}
28722873
2874+ /* * Reinterpret the const_array_ref `a` of type `T` (aka array_ref<const T>) to have a different
2875+ * type `U` using `const_cast`. */
2876+ template <class U , class T , class Shape >
2877+ array_ref<U, Shape> reinterpret_const (const const_array_ref<T, Shape>& a) {
2878+ return array_ref<U, Shape>(const_cast <U*>(a.base ()), a.shape ());
2879+ }
2880+
28732881/* * Reinterpret the shape of the array or array_ref `a` to be a new shape
28742882 * `new_shape`, with a base pointer offset `offset`. */
28752883template <class NewShape , class T , class OldShape >
0 commit comments