title: Why is it not cost effective to inline functions with loops or switch statements?
body: <p>I noticed that <a href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Inline_Functions" rel="noreferrer">Google's C++ style guide</a> cautions against inlining functions with loops or switch statements:</p>
  
  <blockquote>
    <p>Another useful rule of thumb: it's typically not cost effective to
    inline functions with loops or switch statements (unless, in the
    common case, the loop or switch statement is never executed).</p>
  </blockquote>
  
  <p><a href="https://stackoverflow.com/a/21050629/534761">Other comments</a> on StackOverflow have reiterated this sentiment.</p>
  
  <p>Why are functions with loops or <code>switch</code> statements (or <code>goto</code>s) not suitable for or compatible with inlining. Does this apply to functions that contain any type of jump? Does it apply to functions with <code>if</code> statements? Also (and this might be somewhat unrelated), why is inlining functions that return a value discouraged?</p>
  
  <p>I am particularly interested in this question because I am working with a segment of performance-sensitive code. I noticed that after inlining a function that contains a series of <code>if</code> statements, performance degrades pretty significantly. I'm using GNU Make 3.81, if that's relevant.</p>