title: C++ overload return void vs. non-void
body: <p>Is there any particular reason why C++ disallows overloading based on the presence or absence of a return-value?  Like this:</p>
  
  <pre><code>void f();  //(1)
  int f();  //(2)
  
  int main(){
      f(); // calls (1)
      int x = f(); // calls (2)
      return x;
  }
  </code></pre>
  
  <p>The void-variant is called whenever the return-value is ignored, so there shouldn't be any problem with overload-resolution.  Could be useful even in the standard library, for things like <code>vector::pop_back()</code>.  So why is this not allowed?</p>
  
  <p><strong>Edit:</strong> It has been noted that the non-void function can be called in a void context as well.  I'm aware of this.  I just want the compiler to prefer the void function if there is one.  </p>