Menu

boost preprocessor in Loki

2006-07-17
2013-04-08
  • Brent Arias

    Brent Arias - 2006-07-17

    I am only just now learning Loki and typelists (Modern C++ Design text).  But when I see the macros for creating typelists (on page 52), I had to ask if those macros have yet been replaced with boost-style preprocessor macros?

    For example, I could write a boost preprocessor macro that allows me to create a typelist like this:

    TYPELIST(
      (char)
      (int)
      (unsigned int)
    )

    Notice that I did not need to specify how many types are in the list?  So I will ask my question again - has such boost preprocessor utilization been retrofitted into the current Loki implementation?  Yes? No? Why not?

     
    • Peter Kuemmel

      Peter Kuemmel - 2006-07-17

      You could do it (like in boost) completely without the preprocessor, use Loki::Seq.

      For example see test/Factors:

      //with preprocessor:
      Factory< AbstractProduct, int,LOKI_TYPELIST_3(CreateFunctor,int,int) >,

      // w/o prep.
      Factory< AbstractProduct, int,Seq<CreateFunctor,int,int> >,

       
    • Brent Arias

      Brent Arias - 2006-07-21

      I've only read up to page 65 in Alexandrescu's book, so... is Loki::Seq something new since that publication, or will I encounter it later in the book?

       
      • stephan beal

        stephan beal - 2006-07-21

        Yes, Seq came after the book. It appears to be essentially the same as the typelist macros, but the current docs don't cover it (e.g. http://loki-lib.sourceforge.net/html/classes.html\).

         
    • Brent Arias

      Brent Arias - 2006-08-15

      By the way, you said "You could do it (like in boost) completely without the preprocessor, use Loki::Seq. "

      This caught my attention...I was referring to techniques used in Boost's "Preprocessor Metaprogramming", which has allowed me to handle "lists" without specifying number.

      For example, I made an ENUM macro that creates an enumeration, and an array of char* to match the enum.  And it isn't necessary anywhere to specify how long the list is.

      But I took your words as meaning "its not possible to do such list-processing with the preprocessor."  So I'm a little confused...(status quo, actually)

       

Log in to post a comment.