Boost logo

Boost :

From: Daniel Frey (d.frey_at_[hidden])
Date: 2002-07-10 04:25:06


On Wed, 10 Jul 2002 01:37:47 +0200, David Abrahams wrote:

> Looks good. Here are my nits:
>
> +<p>The implementation of these operators requires the compiler to
> +implement the NRVO (named return value optimization) correctly to
> +prevent creating a temporary object. For compilers that don't support
> +the NRVO the code will still work,
>
> Well then the implementation doesn't "require" the NRVO. The
> implementation is more efficient if the NRVO is implemented.

"require"... to prevent creating a temporary object. But english is not
my native language, so I'll try to rephrase it.

> + but there is an alternative
> +implementation style which will create fewer objects in this +case.
> This alternative implementation style copies one of the +arguments by
> value instead of creating a local copy. This has two +drawbacks: The
> implementation is no longer symmetric
>
> You need to explain what "symmetric" means. And why should the user care
> if the implementation is symmetric?
>
> + and the operators
> +signature differs.
>
>>From what? You have to say.
>
> + Most users will not care much about this, as the +asymmetric behaviour
> will only show up if your class has side-effects +for copying object,
> "objects"?---^^^^^^
> +like counting the number of object created. The
> "objects"?-------------------^^^^^^

As we are probably using the NRVO for other boost libraries in the
future and the explanation will become a bit longer than I consider
appropriate for the documentation of the operators library, it may be
worth to add an extra page. Here, we can add some background for those
users that don't know about the NRVO, but the users of the operators
library that already know about the NRVO will see a brief documentation.

> +signature is not important as long as you don't take a pointer (or
> +reference) to the operator. The config system will try to find the
> +best implementation for your compiler automatically, but if your code
> +relies on the exact symmetry or the operators signature to be as
> +documented, you should set
> +<code>BOOST_FORCE_SYMMETRIC_OPERATORS</code> in your user-config.</p>
>
> Why not always keep the signature symmetric and make the copy inside the
> function when there's no NRVO?

Will be contained in the above new documentation about the NRVO itself.

> template in various testing files. Code duplication == bad ;-)

I want to keep them independent. Only the name is the same, but the
implementation isn't - and shouldn't.

Regards, Daniel


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