Default argument vs overloads in C++
问题 For example, instead of void shared_ptr::reset() noexcept; template <typename Y> void shared_ptr::reset(Y* ptr); one may think of template <typename Y = T> void shared_ptr::reset(Y* ptr = nullptr); 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? The same question has been asked for the Kotlin language, and default argument is preferred there. Update: std::unique_ptr::reset() follows