SHARE
TWEET

Concatenate Boost::Dynamic_Bitset

a guest Jun 23rd, 2010 227 Never
  1. typedef boost::dynamic_bitset<> Bits;
  2.  
  3. Bits concatenateBitsets(const Bits& first, const Bits& second)
  4. {
  5.     Bits firstCopy(first);
  6.     Bits secondCopy(second);
  7.  
  8.     //Increase the size of the bit buffer to fit the data being placed in it
  9.     firstCopy.resize(first.size() + second.size());
  10.     secondCopy.resize(first.size() + second.size());
  11.  
  12.     //shift the bits in the firstCopy to the left
  13.     firstCopy <<= second.size();
  14.  
  15.     //"copy" the bits from the secondCopy into the firstCopy
  16.     firstCopy |= secondCopy;
  17.     return firstCopy;
  18. }
RAW Paste Data
Top