Boost logo

Boost :

Subject: Re: [boost] Boost.Math and Math Constants
From: John Maddock (boost.regex_at_[hidden])
Date: 2011-12-08 14:16:28


>I guess (1) would be better than one().
>
>The only real use for them that I know is with
>non-built-in types that lack conversion to/from int.
>(This arises with explicit ctors, etc.)
>
>But since boost policy wants user-defined types to be
>convertible, the int (1) is better than the subroutine
>one(), etc.
>
>I guess this was a relic in my brain.

I think we all have a few of those! :-)

Actually, lets say we want to multiply a number by 10, the "best" method may
vary by type:

x * 10

Will likely be the most efficient method for types that support
mutiplication by integer natively (for example MPFR), where as:

x * ten<mybignum>()

may be more efficient if using a literal would result in a temporary
"mybignum" being constructed.

Sadly nothing is ever as easy as it seems... John.


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