home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,760 of 33,346   
   Seungbeom Kim to Richard   
   Re: Wouldn't it be good to refactor __LI   
   22 Dec 12 17:06:16   
   
   From: musiphil@bawi.org   
      
   On 2012-12-22 12:09, Richard wrote:   
   >   
   > iii) where I need to build a single token from a fixed part and a   
   > varying part.  The preprocessor's token-pasting operator, #, does this   
   > for me and I am unaware of anything else provided by the core language   
   > that can do this.   
      
   You actually mean ## here. :)   
      
   I agree that # is also useful, though. One recent case of mine was   
   something like this:   
      
   void print(std::ostream& os, const char* name, const std::set<...>& set);   
      
   #define PRINT_SET(n) print(*log_file, #n, n)   
        PRINT_SET(added_states);   
        PRINT_SET(removed_states);   
        PRINT_SET(ignored_states);   
        PRINT_SET(unignored_states);   
   #undef PRINT_SET   
      
   I don't see how I could have achieved the same effect with similar   
   or less effort without a macro.   
      
   --   
   Seungbeom Kim   
      
      
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca