Is there any particular reason why at least some boost code uses default parameters. IME, I've found the using overloading is preferable. For example, when using boost::bind, one would have to explicitly give the default parameters whereas one wouldn't if overloading were used. Also, using overloading rather than default parameters when a new function interface is needed can potentially break less client code (eg code that uses the type of the function won't break if overloading were used). Given this, I'd like to hear some arguments for using default arguments over overloading (outside of constructors, of course, where one may not have much of a choice). Thanks, Noel
Noel Yap
Is there any particular reason why at least some boost code uses default parameters. IME, I've found the using overloading is preferable. For example, when using boost::bind, one would have to explicitly give the default parameters whereas one wouldn't if overloading were used.
Sometimes the code is much easier to write with default parameters than with overloading.
Also, using overloading rather than default parameters when a new function interface is needed can potentially break less client code (eg code that uses the type of the function won't break if overloading were used).
Correct.
Given this, I'd like to hear some arguments for using default arguments over overloading (outside of constructors, of course, where one may not have much of a choice).
I don't see why ctors are different from anything else, other than when using enable_if. -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams
-
Noel Yap