Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-08-08 22:02:46


AMDG

Isaac Dupree wrote:
> This documentation is self-contradictory:
>
> http://www.boost.org/doc/libs/1_35_0/libs/preprocessor/doc/ref/add.html
>
> "This macro is the most efficient when x is less than or equal to y.
> However, the efficiency gain is not worth actually comparing the two
> arguments prior to invocation. In other words, x should be the addend
> that is most likely to be the largest of the two operands."
>
> The first sentence says we want (x <= y); the last sentence says we
> want (x > y). Which is it? :-)

The algorithm is

while(y) {
    ++x;
    --y;
}

So the latter is correct.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net