Boost logo

Boost :

From: Vesa Karvonen (vesa_karvonen_at_[hidden])
Date: 2002-04-12 01:29:53


Aleksey Gurtovoy:
>David Abrahams wrote:
>>I'd like to have some simple SELECT_<N>_OF_<M> macros for use with
>>macros like BOOST_PP_REPEAT:
>>
>>#define SELECT_1_OF_2(I,P) I
>>#define SELECT_2_OF_2(I,P) P
>
>MPL calls these BOOST_MPL_PP_PROJECT1ST and BOOST_MPL_PP_PROJECT2ND
>(taking the STL terminology).

The preprocessor library actually contains equivalent macros, but they are
not documented and are currently considered a private implementation detail.
The BOOST_PP_TUPLE_ELEM() macro is implemented using macros that look like
this:

  // ...
  #define BOOST_PP_TUPLE2_ELEM0(A,B) A
  #define BOOST_PP_TUPLE2_ELEM0(A,B) B

  #define BOOST_PP_TUPLE3_ELEM0(A,B,C) A
  #define BOOST_PP_TUPLE3_ELEM1(A,B,C) B
  #define BOOST_PP_TUPLE3_ELEM2(A,B,C) C
  // ...

It seems unlikely that the implementation would change, because the
alternative would be a slower implementation of BOOST_PP_TUPLE_ELEM(). So,
perhaps these macros should be documented.

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk