title: What is the performance of std::bitset?
body: <p>I recently asked a question on <a href="https://softwareengineering.stackexchange.com/questions/284160/is-there-any-advantage-to-c-style-bit-manipulation-over-stdbitset">Programmers</a> regarding reasons to use manual bit manipulation of primitive types over <code>std::bitset</code>.</p>
  
  <p>From that discussion I have concluded that the main reason is its comparatively poorer performance, although I'm not aware of any measured basis for this opinion. So next question is:</p>
  
  <p><strong>what <em>is</em> the performance hit, if any, likely to be incurred by using <code>std::bitset</code> over bit-manipulation of a primitive?</strong></p>
  
  <p>The question is intentionally broad, because after looking online I haven't been able to find anything, so I'll take what I can get. Basically I'm after a resource that provides some profiling of <code>std::bitset</code> vs 'pre-bitset' alternatives to the same problems on some common machine architecture using GCC, Clang and/or VC++. There is a very comprehensive paper which attempts to answer this question for bit vectors:</p>
  
  <p><a href="http://www.cs.up.ac.za/cs/vpieterse/pub/PieterseEtAl_SAICSIT2010.pdf" rel="noreferrer">http://www.cs.up.ac.za/cs/vpieterse/pub/PieterseEtAl_SAICSIT2010.pdf</a></p>
  
  <p>Unfortunately, it either predates or considered out of scope <code>std::bitset</code>, so it focuses on vectors/dynamic array implementations instead.</p>
  
  <p>I really just want to know whether <code>std::bitset</code> is <em>better</em> than the alternatives for the use cases it is intended to solve. I already know that it is <em>easier</em> and <em>clearer</em> than bit-fiddling on an integer, but is it as <em>fast</em>?</p>