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 31,937 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to Vidar Hasfjord   
   Re: Template parameter visibility in spe   
   15 Feb 12 12:11:57   
   
   c6a838f5   
   From: daniel.kruegler@googlemail.com   
      
   On 2012-02-15 02:21, Vidar Hasfjord wrote:   
   > On Feb 12, 12:33 am, Daniel Krügler   
   > wrote:   
   >> [...] there are much easier way to ensure consistency, e.g.   
   >>   
   >> const int MyMessageId = 42;   
   >>   
   >> template<>   struct TDispatch   
   >> {   
   >>        enum {Id = MyMessageId};   
   >> };   
   >   
   > No, this is still violating the DRY principle and hence a maintenance   
   > hazard.   
      
   A different solution would be to define a hopefully *local* macro for   
   this, e.g.   
      
   #define REGISTER_DISPATCH(MessageId)\   
    template<>   struct TDispatch\   
    {\   
           enum {Id = MessageId};\   
    }   
      
   and to expand this as follows   
      
   REGISTER_DISPATCH(WM_COPY);   
   REGISTER_DISPATCH(WM_PASTE);   
   ...   
      
   #undef REGISTER_DISPATCH   
      
   Boost uses this kind of strategy quite often.   
      
   HTH & Greetings from Bremen,   
      
   Daniel Krügler   
      
      
   --   
         [ 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