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,762 of 33,346   
   Bo Persson to All   
   Re: mutable keyword applied to templated   
   26 Dec 12 10:51:32   
   
   From: bop@gmb.dk   
      
   Chris Vine skrev 2012-12-26 14:38:   
   >   
   > g++ accepts this, but clang++ does not:   
   >   
   >     template    
   >     struct Test {   
   >       mutable T t;   
   >       Test(): t(T()) {}   
   >     };   
   >   
   >     int main() {   
   >       Test t;   
   >     }   
   >   
   > clang++-3.2 fails with the message "error: 'mutable' and 'const'   
   > cannot be mixed".   
   >   
   > Is clang++ correct in failing to accept this?   
   >   
      
   Probably.   
      
   The C++11 standard says (7.1.1 Storage class specifiers, §10):   
      
   "The mutable specifier can be applied only to names of class data   
   members (9.2) and cannot be applied to names declared const or static,   
   and cannot be applied to reference members."   
      
   It doesn't mention templates, but likely applies there too.   
      
      
   Bo Persson   
      
      
   --   
         [ 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