Changeset 1abcec9b for libcfa/src/collections/array.hfa
- Timestamp:
- Apr 13, 2026, 3:05:44 AM (2 weeks ago)
- Branches:
- master
- Children:
- 5b21636b
- Parents:
- 2581f1e
- File:
-
- 1 edited
-
libcfa/src/collections/array.hfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/collections/array.hfa
r2581f1e r1abcec9b 1 1 #pragma once 2 3 2 4 3 … … 176 175 } 177 176 177 // RAII for copying interacts poorly with CFA RAII's default (quasi-mandate) to take 178 // 'src' parameters by value; note doc/proposals/autogen.md suggests changing this pattern. 179 // If Timmed offers a by-value copy-ctor, then 180 // - the array copy-ctor will make lots of memcpys of them 181 // - the array assignment operator will make temporaries (and call their RAII, implying 182 // the above memcpys) of them 183 // - the array assignment operator will scale poorly to higher dimensionality due to #226 184 // Furthermore, enabling this experimental flag breaks some multidimensional behaviour, 185 // as illustraed by a test failure in array-md-sbscr-cases, which has not been investigated. 186 // These limitations kick in upon calling the copy operation, not upon including the definitions. 187 // Design choice here: 188 // - FIX ME: deal with `const &` on params 189 #ifdef EXPERIMENTAL_ARRAY_ALLOW_COPY_RAII 190 // call copy ctor on elements 191 // array(float, 5) y; // given 192 // array(float, 5) x = y; // <- do 193 forall( [N], S & | sized(S), Timmed *, Tbase & | { void ?{}( Timmed &, Timmed & ); } ) 194 static inline void ?{}( arpk( N, S, Timmed, Tbase ) & this, arpk( N, S, Timmed, Tbase ) & src ) { 195 ?{}( this, delay_init ); 196 for (i; N) ?{}( (Timmed &)this.strides[i], src[i] ); 197 } 198 forall( [N], S & | sized(S), Timmed *, Tbase & | { void ?{}( Timmed &, const Timmed & ); } ) 199 static inline void ?{}( arpk( N, S, Timmed, Tbase ) & this, arpk( N, S, Timmed, Tbase ) & src ) { 200 ?{}( this, delay_init ); 201 for (i; N) ?{}( (Timmed &)this.strides[i], src[i] ); 202 } 203 204 // call assignment on elements 205 // array(float, 5) x, y; // given 206 // x = y; // <- do 207 forall( [N], S & | sized(S), Timmed & | is_value(Timmed), Tbase & ) 208 static inline void ?=?( arpk( N, S, Timmed, Tbase ) & this, arpk( N, S, Timmed, Tbase ) & src ) { 209 for (i; N) this[i] = src[i]; 210 return src; 211 } 212 forall( [N], S & | sized(S), Timmed &, Tbase & | { void ?=?( Timmed &, const Timmed & ); } ) 213 static inline void ?=?( arpk( N, S, Timmed, Tbase ) & this, arpk( N, S, Timmed, Tbase ) & src ) { 214 for (i; N) this[i] = src[i]; 215 return src; 216 } 217 #endif // EXPERIMENTAL_ARRAY_ALLOW_COPY_RAII 218 178 219 179 220 //
Note:
See TracChangeset
for help on using the changeset viewer.