Boost logo

Boost Users :

Subject: Re: [Boost-users] boost/preprocessor checking if argument is a constant
From: Bryce Lelbach (admin_at_[hidden])
Date: 2010-10-08 15:37:49


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I replied your question on stackoverflow. IMHO this is not a role for
cpp. Let the compiler take care of optimization here.

On Fri, 8 Oct 2010 12:04:30 -0400
Z S <baltcode_at_[hidden]> wrote:

> All the BOOST_PP functions only work on integer constants. I want to
> write macros, where the same interface can be used for both constants
> and variables, and only call the BOOST_PP if the argument is a
> constant, and use runtime code if it is a variable. For example,
>
> #define TWICE(n) BOOST_PP_IF( _IS_CONSTANT(n), \
> BOOST_PP_MUL(n,2), \
> ( (n) * 2) )
>
> For more details, you can also see the original question here :
> http://stackoverflow.com/questions/3884489/mixing-variables-and-integer-constants-in-the-boost-preprocessor
>
> Is there a way to do so? The C preprocessor knows whether something is
> a constant, so we should be able to do this somehow. Or should I
> suggest this as a feature request for the Boost Preprocessor library?
>
> Thanks!



- --
Bryce Lelbach aka wash
http://groups.google.com/group/ariel_devel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkyvcw0ACgkQO/fqqIuE2t6ywgCcDa7FzHr/6lHZOzaetogrhTTC
MzoAoO/MwDqzqgbwO2i0Rk8LUoEvMd7+
=0PgS
-----END PGP SIGNATURE-----


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