Boost logo

Boost Users :

From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2006-11-13 16:18:38


On 11/11/06, Michael Marcin <mmarcin_at_[hidden]> wrote:
...

Finally I'm using this class to replace a lot of hardcoded / macro logic and
> often as an optimization the code uses binary shifts to represent power of
> 2
> multiply/divides. Going forward these divides need to work with both
> fixed
> and floating point types so f >> 1 needs to change to f / 2. Is it
> possible
> to create an overload for the / and * operators that determine if the
> operand is an integral constant and is a power of 2 and use a binary shift
> internally?

If, in the end, the thing you are shifting is an integer type, the compiler
will do the '/ 2' => '>> 1' substitution for you. So don't worry about it.

Thanks,
>
> Michael Marcin
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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