title: Optimization of detecting integer with only 1 bit set
body: <p>I have a function:</p>
  
  <pre><code>inline uint32_t ShiftOf(uint32_t v)
  {
      for (uint32_t s = 0; s &lt; 32; ++s)
      {
          if (v == 1 &lt;&lt; s)
              return s;
      }
      return -1;
  }
  </code></pre>
  
  <p>Is there any way to optimize it?</p>