title: Default argument vs overloads in C++
body: <p>For example, instead of</p>
  
  <pre><code>void shared_ptr::reset() noexcept;
  template &lt;typename Y&gt;
  void shared_ptr::reset(Y* ptr);
  </code></pre>
  
  <p>one may think of</p>
  
  <pre><code>template &lt;typename Y = T&gt;
  void shared_ptr::reset(Y* ptr = nullptr);
  </code></pre>
  
  <p>I think performance difference is negligible here, and the second version is more concise. Is there any specific reason the C++ standard goes the first way?</p>
  
  <p>The <a href="https://stackoverflow.com/q/39733830/1348273">same question</a> has been asked for the Kotlin language, and default argument is preferred there.</p>
  
  <p><strong>Update:</strong></p>
  
  <p><code>std::unique_ptr::reset()</code> follows the default argument design (see <a href="http://en.cppreference.com/w/cpp/memory/unique_ptr/reset" rel="nofollow noreferrer">here</a>). So I think the reason <code>std::shared_ptr::reset()</code> uses overloads is because they have different exception specifications.</p>