
7 Dec
2024
7 Dec
'24
12:35 a.m.
Andrey Semashev wrote:
To convert all the checks that are done in runtime with the code I presented earlier you would have to convert that loop to a series of statements such as this:
x[ 0 ] = detail::read32le( block.subspan<0, 4>() ); x[ 1 ] = detail::read32le( block.subspan<4, 4>() ); x[ 3 ] = detail::read32le( block.subspan<8, 4>() ); x[ 4 ] = detail::read32le( block.subspan<12, 4>() ); // ... x[ 15 ] = detail::read32le( block.subspan<60, 4>() );
Or perform some kind of tricks with variadic templates and fold expressions.
You can write this with mp_for_each, but it's not necessary because compilers figure out the for loop easily: https://godbolt.org/z/d861cPf1K