@@ -1240,7 +1240,7 @@ NDARRAY_HOST_DEVICE auto transpose_impl(const Shape& shape, index_sequence<Extra
1240
1240
shape.template dim <DimIndices>()..., shape.template dim <sizeof ...(DimIndices) + Extras>()...);
1241
1241
}
1242
1242
1243
- } // namespace internal
1243
+ } // namespace internal
1244
1244
1245
1245
/* * Create a new shape using a list of `DimIndices...` to use as the
1246
1246
* 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
1252
1252
*
1253
1253
* Examples:
1254
1254
* - `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. */
1256
1257
template <size_t ... DimIndices, class ... Dims,
1257
1258
class = internal::enable_if_permutation<sizeof ...(DimIndices), DimIndices...>>
1258
1259
NDARRAY_HOST_DEVICE auto transpose (const shape<Dims...>& shape) {
@@ -1391,8 +1392,7 @@ NDARRAY_INLINE NDARRAY_HOST_DEVICE void for_each_value_in_order(
1391
1392
1392
1393
// Scalar buffers are a special case. The enable_if here (and above) are a workaround for a bug in
1393
1394
// 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 >
1396
1396
NDARRAY_INLINE NDARRAY_HOST_DEVICE void for_each_value_in_order (
1397
1397
const std::tuple<>& extent, Fn&& fn, Ptrs... ptrs) {
1398
1398
fn (*std::get<0 >(ptrs)...);
@@ -1553,7 +1553,8 @@ NDARRAY_HOST_DEVICE auto make_compact(const Shape& s) {
1553
1553
1554
1554
/* * A `shape` where all extents (and automatically computed compact strides) are constant. */
1555
1555
template <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>()...)));
1557
1558
1558
1559
/* * Returns `true` if a shape `src` can be assigned to a shape of type
1559
1560
* `ShapeDst` without error. */
@@ -2870,6 +2871,13 @@ const_array_ref<U, Shape> reinterpret(const array<T, Shape, Alloc>& a) {
2870
2871
return reinterpret<const U>(a.cref ());
2871
2872
}
2872
2873
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
+
2873
2881
/* * Reinterpret the shape of the array or array_ref `a` to be a new shape
2874
2882
* `new_shape`, with a base pointer offset `offset`. */
2875
2883
template <class NewShape , class T , class OldShape >
0 commit comments