|
Boost Users : |
Subject: [Boost-users] boost/preprocessor checking if argument is a constant
From: Z S (baltcode_at_[hidden])
Date: 2010-10-08 12:04:30
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!
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