|
Boost Users : |
Subject: Re: [Boost-users] PP: 2 to the power x macro
From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2010-02-04 11:37:23
2010/2/4 Hicham Mouline <hicham_at_[hidden]>
> So Roman, what do you think of my POWER2 implementation?
>
> It is very slow (to preprocess) in an actual example I have.
> Can anyone see a faster implementation?
I'd use something like this:
#define POWER_2_0 1
#define POWER_2_1 2
#define POWER_2_2 4
#define POWER_2_3 8
#define POWER_2_4 16
#define POWER_2_5 32
#define POWER_2_6 64
#define POWER_2_7 128
#define POWER_2_8 256
#define POWER_2(n) BOOST_PP_CAT(POWER_2_, n)
It's obviously fast and obviously correct.
Roman Perepelitsa.
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