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,644 of 33,346    |
|    Matt Calabrese to All    |
|    Is this a violation of the ODR?    |
|    12 Nov 12 23:14:02    |
   
   From: rivorus@googlemail.com   
      
   While working on a library, I unfortunately need to dance on the edge   
   of ODR violations. Through several little tricks, I believe I may be   
   safe, but I'm not certain. Before anyone asks, this sounds like an   
   "XY problem," but you're going to just have to trust me that I need   
   to do something hairy like this, and details for why are too   
   complicated to get into here. Anyway, consider the following example,   
   obviously reduced from what I'm actually doing:   
      
   ////////////////////   
   // namespace { bool foo(); }   
   // inline void bar() { decltype( foo() ) foobar; }   
   ////////////////////   
      
   So, if the above code is inside of a header file that is included by   
   two or more different translation units, is the ODR technically still   
   violated? In other words, if I'm only doing something different in an   
   unevaluated context, but the resultant type is always the same in   
   every translation unit, is what I'm doing technically okay? Should I   
   worry about this even if it is questionable whether or not this is   
   valid? I don't see how this could possibly cause a problem, but for   
   the sake of being pedantic, I'd like to know if I'm committing one of   
   the worst of all C++ sins.   
      
      
   --   
    [ 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