Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2006-01-14 14:18:28


Arkadiy Vertleyb wrote:
> "Cromwell Enage" <sponage_at_[hidden]> wrote
>
>
> File iteration works good with typeof,

> and you don't have to explicitly
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> specify IDs.
^^^^^^^^^^^^^^

Curious question: does it work like this

    if IS_ITERATING then
      id <- 0
      for i <- 0, i < ITERATION_DEPTH
        id <- id * ITERATION_FINISH(i) + FRAME_ITERATION(i)
      id <- encode_full_id(BOOST_PP_COUNTER, id)

?

>
>>Please do adopt this strategy. Currently this kind of
>>code doesn't work:
>>
>>BOOST_TYPEOF_REGISTER_TYPE(
>
> ^^^^^
>
>> boost::mpl::math::string_c_to_double
>> , BOOST_MPL_PP_ARG_SEQ(unsigned char, 40)
>>)
>>

Are you sure the output of BOOST_MPL_PP_ARG_SEQ is a sequence?

   (unsigned char)(unsigned char)(unsigned char)(unsigned char) [... x10 ]

>>BOOST_MPL_PP_ARG_SEQ uses BOOST_PP_REPEAT to create a
>>sequence of N elements containing the specified
>>primitive integral type.
>
>
> Do you mean BOOST_TYPEOF_REGISTER_TEMPLATE? I am not sure REPEAT is a
> problem here.

Because BOOST_PP_REPEAT should really not be a problem here.

Rescanning happens /after/ argument substitution [ 16.3.4.-1 ] and the replacement
restrictions for rescanning [ 16.3.4-2 ] do not apply for argument substitution [
16.3.1 "A parameter in the replacement list [...] is replaced by the corresponding
argument after /all/ macros contained therein have been expanded" ].

Simple example:

   #include <boost/preprocessor/cat.hpp>
   BOOST_PP_CAT(f,BOOST_PP_CAT(o,o)) // expands to foo, no tricks necessary

The proof for BOOST_PP_REPEAT (note that I use BOOST_PP_REPEAT_1ST to ensure they
are nonreentrant):

   #include <boost/preprocessor/cat.hpp>
   #include <boost/preprocessor/seq/size.hpp>
   #include <boost/preprocessor/seq/elem.hpp>
   #include <boost/preprocessor/repetition/repeat.hpp>

   #define make_seq_elem(z,i,d) (foo)
   #define make_seq(n) BOOST_PP_REPEAT_1ST(n,make_seq_elem,-)

   #define for_each(seq,m) BOOST_PP_REPEAT_1ST(BOOST_PP_SEQ_SIZE(seq),m,seq)

   #define seq_suffix_elem_idx(z,i,seq) (BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(i,seq),i))

   for_each(make_seq(10),seq_suffix_elem_idx)
   // (foo0) (foo1) (foo2) (foo3) (foo4) (foo5) (foo6) (foo7) (foo8) (foo9)

Regards,

Tobias


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