Boost logo

Boost :

Subject: Re: [boost] Library design Q : overloads v/s default args
From: David Abrahams (dave_at_[hidden])
Date: 2010-06-20 14:46:39


At Sun, 20 Jun 2010 18:46:16 +0200,
Thomas Klimpel wrote:

> > Boost.Parameter does a very good approximation of perfect forwarding,
> > generating T&/T const& parameters for all out- and in/out- parameters.
> > It does erase rvalue-ness, but that's pretty much a given with C++03
> > that AFAICT nobody knows how to avoid.
>
> In fact, Rutgers code doesn't erase rvalue-ness as well,

I think you mean *does*, right?

> it was just me misinterpreting things. So what he does is really
> just a "perfect forwarding" emulation, just as Boost.Parameter
> does. However, I wonder whether Boost.Parameter uses the
> preprocessor to implicitly generate a similar amount of code as
> Rutgers solution explicitly generates.

Well, Boost.Parameter has the advantage of knowing which parameters
need to be passed by non-const reference, so unless all your
parameters are “out” or “in_out” parameters, it probably does better
than Rutger's solution.

> In that case, I would wonder whether it would be possible to
> selectively turn off the T const& overload for parameters that don't
> need it (so that we could still use the "workaround" mentioned
> above).

Why would you want to turn that one off, as opposed to the T& one (as
Boost.Parameter does)? Seems kinda crazy.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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