On Mon, Jun 18, 2012 at 12:34 PM, Jeremiah Willcock <jewillco@osl.iu.edu> wrote:
On Mon, 18 Jun 2012, Jeffrey Lee Hellrung, Jr. wrote:

On Mon, Jun 18, 2012 at 12:25 PM, Jeremiah Willcock <jewillco@osl.iu.edu> wrote:
     On Mon, 18 Jun 2012, Jeffrey Lee Hellrung, Jr. wrote:

           On Mon, Jun 18, 2012 at 10:35 AM, Jeremiah Willcock <jewillco@osl.iu.edu> wrote:
                Boost.Preprocessor has a macro BOOST_PP_INTERCEPT to eat a numeric value that it is token-concatenated onto.  Is there a
           similar macro that just
                returns the value?  I.e., some BOOST_PP_EMPTY_FOR_CONCAT such that BOOST_PP_EMPTY_FOR_CONCAT ## 3 turns into 3?  As with
           BOOST_PP_INTERCEPT, it
                only needs to work for small integer values.  Is there some other technique I can use for this?  I am using it to generate
           std::get<>
                invocations in BOOST_PP_ENUM_BINARY_PARAMS.  Thank you for your help.


           I don't know any such facility in Boost.PP, but it's pretty trivial to generate:

           #define X0 0
           #define X1 1
           #define X2 2
           // etc.

           ...which makes me think I might be overlooking something in Boost.PP :/

           Somewhat related: what do your ENUM_BINARY_PARAMS invocations look like? I know I've gotten away with cat'ing template parameter
           delimiters ("<" and ">")
           against preprocessor integer tokens.


     I'm not using this code anymore, but it was basically:

     BOOST_PP_ENUM_BINARY_PARAMS(nparams, std::get<ZZZ, >(tup) BOOST_PP_INTERCEPT)

     where ZZZ is the identity-type macro discussed in the email.  Even using something that I would expect to work like + as ZZZ breaks since
     apparently signs aren't allowed at the beginnings of pp-tokens.  I'm using GCC 4.7, and it seems to be strict about concatenations.

 
So, just to confirm,

BOOST_PP_ENUM_BINARY_PARAMS( nparams, std::get<, >(tup) BOOST_PP_INTERCEPT )

(i.e., with ZZZ being an empty token) does not work with gcc 4.7?

Unless "empty token" means something other than putting nothing there, it expands to what I want but produces errors:

foo.cpp:3:1: error: pasting "<" and "0" does not give a valid preprocessing token
foo.cpp:3:1: error: pasting "<" and "1" does not give a valid preprocessing token
foo.cpp:3:1: error: pasting "<" and "2" does not give a valid preprocessing token
foo.cpp:3:1: error: pasting "<" and "3" does not give a valid preprocessing token
foo.cpp:3:1: error: pasting "<" and "4" does not give a valid preprocessing token
 std::get< 0 >(tup) , std::get< 1 >(tup) , std::get< 2 >(tup) , std::get< 3 >(tup) , std::get< 4 >(tup)

When trying to expand:

BOOST_PP_ENUM_BINARY_PARAMS(5, std::get<, >(tup) BOOST_PP_INTERCEPT)

Sounds like I might need to change my preprocessor programming habits :(

How about using a leading 0?

BOOST_PP_ENUM_BINARY_PARAMS( nparams, std::get< 0, >(tup) BOOST_PP_INTERCEPT )

- Jeff