1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| template<class InIt, class OutIt>
inline OutIt copyn(size_t n, InIt in, OutIt out)
{
for (; n>=UNROLL_SIZE; n-=UNROLL_SIZE)
{
*out=*in;
#if UNROLL_SIZE>1
*++out=*++in;
#endif
#if UNROLL_SIZE>2
*++out=*++in;
#endif
#if UNROLL_SIZE>3
*++out=*++in;
#endif
#if UNROLL_SIZE>4
*++out=*++in;
#endif
#if UNROLL_SIZE>5
*++out=*++in;
#endif
#if UNROLL_SIZE>6
*++out=*++in;
#endif
#if UNROLL_SIZE>7
*++out=*++in;
#endif
++in; ++out;
}
#if UNROLL_SIZE>1
switch (n)
{
#if UNROLL_SIZE>7
case 7: *out++=*in++;
case 6: *out++=*in++;
case 5: *out++=*in++;
case 4: *out++=*in++;
#endif
#if UNROLL_SIZE>3
case 3: *out++=*in++;
case 2: *out++=*in++;
#endif
case 1: *out++=*in++;
}
#endif
return ++out;
} |