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,458 of 33,346   
   Johannes Schaub to All   
   Re: Are enums allowed as template parame   
   06 Jul 12 15:31:09   
   
   From: schaub.johannes@googlemail.com   
      
   Am 06.07.2012 20:57, schrieb DeMarcus:   
   > Hi,   
   >   
   > Consider this template where I want to have a default initialization.   
   >   
   > template   
   > class Initialized   
   > {   
   > public:   
   >      Initialized() : t(init) {}   
   >      T get() const { return t; }   
   >   
   > private:   
   >      T t;   
   > };   
   >   
   >   
   > int main()   
   > {   
   >      enum Vals   
   >      {   
   >         ONE,   
   >         TWO   
   >      };   
   >   
   >      Initialized one;   
   >      std::cout << one.get() << std::endl;   
   >   
   >      return 0;   
   > }   
   >   
   > Above doesn't work in C++03 but works in C++11. Is it §14.1/4 and §14.3   
   > that makes this possible?   
   >   
      
   The reason is not "enums are disallowed as template parameters in   
   C++03", but "local type template arguments are disallowed by C++03".   
   C++11 lifted that restriction.   
      
   Enums have always worked as template parameter for templates.   
      
      
   --   
         [ 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