Boost logo

Boost :

Subject: [boost] Library design Q : overloads v/s default args
From: Roshan (roshan_naik_at_[hidden])
Date: 2010-06-20 05:11:47


  Hope this is not a silly question. The C++ Standard library does not use
default arguments. Instead it provides an additional overload. Anybody
know why ?

For e.g.

It provides the following two overloads for accumulate :

template<class Itr, class T>
accumulate(Itr first, Itr last, T init);

template<class Itr, class T, class BinOp>
accumulate(Itr first, Itr last, T init, BinOp op);

instead of:

template<class Itr, class T, class BinOp>
accumulate(Itr first, Itr last, T init, BinOp op = std::plus<T>() );

I am wondering if there is any reason to avoid default arguments in
general purpose libraries ?

- Roshan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk