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,459 of 33,346   
   DeMarcus to Seungbeom Kim   
   Re: Are enums allowed as template parame   
   07 Jul 12 12:51:04   
   
   From: use_my_alias_here@hotmail.com   
      
   On 2012-07-07 00:24, Seungbeom Kim wrote:   
   > On 2012-07-06 11:57, DeMarcus wrote:   
   >>   
   >> 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?   
   >   
   > It's not because C++03 disallowed enums as template parameters,   
   > but because it disallowed local types as template parameters.   
   >   
   > Move your definition of Vals to the namespace scope, and it is   
   > accepted by both C++03 and C++11.   
   >   
      
   Thanks it worked, but I bump into another problem. Maybe it's a very   
   simple mistake I'm doing but I can't see what.   
      
   I've moved out Vals as you said and it worked, but then I changed   
   Initialized one;   
   to   
   Initialized one;   
      
   and I get   
   In function ‘int main(int, char**)’:   
   error: template argument 2 is invalid   
   error: invalid type in declaration before ‘;’ token   
      
   using g++ 4.7.1   
      
   (it works if I add -std=c++0x)   
      
   Is this a bug or have I misunderstood something?   
      
      
   Thanks,   
   Daniel   
      
      
   --   
         [ 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