Jul 23, 2013 at 2:13am UTC
Say I have the following variables:
1 2
bitset <3> rank, file;
bitset<6> square;
Is there other way to assign the file bits to be the first 3 bits of square then the rank bits the last 3 other than
1 2 3 4
for (x = 0; x<=2; x++) {
square[x] = file[x];
square[x+3] = rank[x];
}
Thanks.
Last edited on Jul 23, 2013 at 2:13am UTC
Jul 23, 2013 at 2:34am UTC
1 2 3 4
square.reset();
square |= rank;
square <<= 3;
square |= file;
Would that work?
Last edited on Jul 23, 2013 at 2:36am UTC
Jul 23, 2013 at 2:34am UTC
You might be able to do an std::copy() or something, but honestly that is pretty simple.
Jul 23, 2013 at 4:32am UTC
@Zhuge that would not save processing time. I am looking for an optimized code.
@Daleth: I think so, that is very logical.
Last edited on Jul 23, 2013 at 4:44am UTC
Jul 23, 2013 at 4:44am UTC
Ah, in that case then I'd guess either what you have or Daleth's suggestion. Try checking the assembly generated for each code snippet and see if either is obviously faster.