@@ -39,6 +39,7 @@ template< typename T, int DIM0 >
3939struct CArrayWrapper < T, DIM0 >
4040{
4141 // default constructor
42+ HPCREACT_HOST_DEVICE
4243 constexpr CArrayWrapper () = default;
4344
4445 /* *
@@ -53,6 +54,7 @@ struct CArrayWrapper< T, DIM0 >
5354 *
5455 * @note No runtime bounds checking is performed on the initializer size.
5556 */
57+ HPCREACT_HOST_DEVICE
5658 constexpr CArrayWrapper ( std::initializer_list< T > init )
5759 {
5860 // static_assert(init.size() == DIM0, "Size mismatch"); // needs c++20
@@ -66,6 +68,7 @@ struct CArrayWrapper< T, DIM0 >
6668 * @brief Copy constructor.
6769 * @param src The source CArrayWrapper to copy from.
6870 */
71+ HPCREACT_HOST_DEVICE
6972 constexpr CArrayWrapper ( CArrayWrapper const & src )
7073 {
7174 for ( std::size_t i = 0 ; i < DIM0; i++ )
@@ -79,27 +82,31 @@ struct CArrayWrapper< T, DIM0 >
7982 * @param dim The index (must be in range [0, DIM0)).
8083 * @return Reference to the element at the specified index.
8184 */
85+ HPCREACT_HOST_DEVICE
8286 constexpr HPCREACT_HOST_DEVICE inline T & operator ()( int const dim ) { return data[dim]; }
8387
8488 /* *
8589 * @brief Read-only access to an element by index (const overload).
8690 * @param dim The index (must be in range [0, DIM0)).
8791 * @return Const reference to the element at the specified index.
8892 */
93+ HPCREACT_HOST_DEVICE
8994 constexpr HPCREACT_HOST_DEVICE inline T const & operator ()( int const dim ) const { return data[dim]; }
9095
9196 /* *
9297 * @brief Subscript operator for read/write access.
9398 * @param dim The index (must be in range [0, DIM0)).
9499 * @return Reference to the element at the specified index.
95100 */
101+ HPCREACT_HOST_DEVICE
96102 constexpr HPCREACT_HOST_DEVICE inline T & operator []( int const dim ) { return data[dim]; }
97103
98104 /* *
99105 * @brief Subscript operator for read-only access (const overload).
100106 * @param dim The index (must be in range [0, DIM0)).
101107 * @return Const reference to the element at the specified index.
102108 */
109+ HPCREACT_HOST_DEVICE
103110 constexpr HPCREACT_HOST_DEVICE inline T const & operator []( int const dim ) const { return data[dim]; }
104111
105112 // / The underlying 1D C-style array.
@@ -120,12 +127,14 @@ template< typename T, int DIM0, int DIM1 >
120127struct CArrayWrapper < T, DIM0, DIM1 >
121128{
122129 // default constructor
130+ HPCREACT_HOST_DEVICE
123131 constexpr CArrayWrapper () = default;
124132
125133 /* *
126134 * @brief Copy constructor.
127135 * @param src The source CArrayWrapper to copy from.
128136 */
137+ HPCREACT_HOST_DEVICE
129138 constexpr CArrayWrapper ( CArrayWrapper const & src )
130139 {
131140 for ( std::size_t i = 0 ; i < DIM0; i++ )
@@ -150,6 +159,7 @@ struct CArrayWrapper< T, DIM0, DIM1 >
150159 *
151160 * @note No runtime bounds checking is performed on the initializer dimensions.
152161 */
162+ HPCREACT_HOST_DEVICE
153163 constexpr CArrayWrapper ( std::initializer_list< std::initializer_list< T > > init )
154164 {
155165 // static_assert(init.size() == DIM0, "Size mismatch"); // needs c++20
@@ -172,6 +182,7 @@ struct CArrayWrapper< T, DIM0, DIM1 >
172182 * @param dim1 Index in the second dimension (range [0, DIM1)).
173183 * @return Reference to the element at the specified 2D location.
174184 */
185+ HPCREACT_HOST_DEVICE
175186 constexpr HPCREACT_HOST_DEVICE inline T & operator ()( int const dim0, int const dim1 )
176187 {
177188 return data[dim0][dim1];
@@ -183,6 +194,7 @@ struct CArrayWrapper< T, DIM0, DIM1 >
183194 * @param dim1 Index in the second dimension (range [0, DIM1)).
184195 * @return Const reference to the element at the specified 2D location.
185196 */
197+ HPCREACT_HOST_DEVICE
186198 constexpr HPCREACT_HOST_DEVICE inline T const & operator ()( int const dim0, int const dim1 ) const
187199 {
188200 return data[dim0][dim1];
@@ -195,6 +207,7 @@ struct CArrayWrapper< T, DIM0, DIM1 >
195207 *
196208 * This allows usage like `obj[dim0][dim1]`.
197209 */
210+ HPCREACT_HOST_DEVICE
198211 constexpr HPCREACT_HOST_DEVICE inline T ( & operator []( int const dim0 ))[DIM1]
199212 {
200213 return data[dim0];
@@ -205,6 +218,7 @@ struct CArrayWrapper< T, DIM0, DIM1 >
205218 * @param dim0 The row index (range [0, DIM0)).
206219 * @return Const reference to an array of type T[DIM1].
207220 */
221+ HPCREACT_HOST_DEVICE
208222 constexpr HPCREACT_HOST_DEVICE inline T const (&operator []( int const dim0 ) const )[DIM1]
209223 {
210224 return data[dim0];
@@ -229,6 +243,7 @@ template< typename T, int DIM0, int DIM1, int DIM2 >
229243struct CArrayWrapper < T, DIM0, DIM1, DIM2 >
230244{
231245 // default constructor
246+ HPCREACT_HOST_DEVICE
232247 constexpr CArrayWrapper () = default;
233248
234249 /* *
@@ -254,6 +269,7 @@ struct CArrayWrapper< T, DIM0, DIM1, DIM2 >
254269 * @note This constructor does not perform size validation. Incorrect initializer sizes
255270 * may lead to undefined behavior.
256271 */
272+ HPCREACT_HOST_DEVICE
257273 constexpr CArrayWrapper ( std::initializer_list< std::initializer_list< std::initializer_list< T > > > init )
258274 {
259275 // static_assert(init.size() == DIM0, "Size mismatch"); // needs c++20
@@ -286,6 +302,7 @@ struct CArrayWrapper< T, DIM0, DIM1, DIM2 >
286302 * @note Currently, this function incorrectly indexes data[dim0][dim1], missing dim2.
287303 * It should be `data[dim0][dim1][dim2]`. Please correct if intended.
288304 */
305+ HPCREACT_HOST_DEVICE
289306 constexpr HPCREACT_HOST_DEVICE inline T & operator ()( int const dim0, int const dim1, int const dim2 )
290307 {
291308 // NOTE: This looks like a bug in your original code. Should be data[dim0][dim1][dim2].
@@ -299,6 +316,7 @@ struct CArrayWrapper< T, DIM0, DIM1, DIM2 >
299316 * @param dim2 Index in the third dimension (range [0, DIM2)).
300317 * @return Const reference to the element at the specified 3D location.
301318 */
319+ HPCREACT_HOST_DEVICE
302320 constexpr HPCREACT_HOST_DEVICE inline T const & operator ()( int const dim0, int const dim1, int const dim2 ) const
303321 {
304322 // NOTE: Same potential bug as above. Should be data[dim0][dim1][dim2].
@@ -312,6 +330,7 @@ struct CArrayWrapper< T, DIM0, DIM1, DIM2 >
312330 *
313331 * This allows usage like `obj[dim0][dim1][dim2]`.
314332 */
333+ HPCREACT_HOST_DEVICE
315334 constexpr HPCREACT_HOST_DEVICE inline T ( & operator []( int const dim0 ))[DIM1][DIM2]
316335 {
317336 return data[dim0];
@@ -322,6 +341,7 @@ struct CArrayWrapper< T, DIM0, DIM1, DIM2 >
322341 * @param dim0 The slice index (range [0, DIM0)).
323342 * @return Const reference to an array of type T[DIM1][DIM2].
324343 */
344+ HPCREACT_HOST_DEVICE
325345 constexpr HPCREACT_HOST_DEVICE inline T const (&operator []( int const dim0 ) const )[DIM1][DIM2]
326346 {
327347 return data[dim0];
0 commit comments