title: Is it still better to prefer pre-increment over post-increment?
body: <p>It used to be the case that pre-increment would be preferred because an overloaded post-increment on a class necessitated the return of a temporary copy that represented the state of the object before the increment.</p>
  
  <p>It seems this is no longer a serious concern (so long as inlining is in place), since my old C++ compiler (GCC 4.4.7) seems to optimize the following two functions down into identical code:</p>
  
  <pre><code>class Int {
      //...
  public:
      Int (int x = 0);
      Int &amp; operator ++ ();
      Int operator ++ (int) {
          Int x(*this);
          ++*this;
          return x;
      }
  };
  
  Int &amp; test_pre (Int &amp;a) {
      ++a;
      return a;
  }
  
  Int &amp; test_post (Int &amp;a) {
      a++;
      return a;
  }
  </code></pre>
  
  <p>The resulting assembly for both functions is:</p>
  
  <pre><code>    .cfi_startproc
      .cfi_personality 0x3,__gxx_personality_v0
      pushq   %rbx
      .cfi_def_cfa_offset 16
      .cfi_offset 3, -16
      movq    %rdi, %rbx
      call    _ZN3IntppEv
      movq    %rbx, %rax
      popq    %rbx
      .cfi_def_cfa_offset 8
      ret
      .cfi_endproc
  </code></pre>
  
  <blockquote>
    <p><sub>If nothing is inlined, however, there seems to still be a benefit to preferring pre-increment to post-increment, since <code>test_post</code> is forced to call out into <code>operator++(int)</code>.</sub></p>
  </blockquote>
  
  <p>Let's assume <code>operator++(int)</code> is inlined as an idiomatic copy constructor, call to the pre-increment, and return of the copy, as illustrated above. If the copy constructor is <s>inlined or</s> the default copy constructor implementation, is that sufficient information for the compiler to optimize post-increment so that <code>test_pre</code> and <code>test_post</code> become identical functions? If not, what other information is required?</p>