Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Concatenate Boost::Dynamic_Bitset

By: a guest on Jun 23rd, 2010  |  syntax: C++  |  size: 0.54 KB  |  views: 209  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data