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)   
|