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,104 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to All   
   Re: trouble with decltype   
   07 Apr 12 14:28:11   
   
   37e5289f   
   From: daniel.kruegler@googlemail.com   
      
   Am 06.04.2012 21:55, schrieb Brendan:   
   > I'm getting some weird behavior from decltype, at least on my compiler   
   > (g++ 4.6). Could someone explain whether this is standard and why?   
   >   
   > Consider:   
   >   
   > std::vector  vec;   
   > decltype(vec)::value_type x;   
   >   
   > The second line gives me the error:   
   > expected initializer before "x"   
   >   
   > I'm not sure what that means in this context. I'd expect my decltype   
   > code to be the same as:   
   >   
   > std::vector::value_type x;   
   >   
   > Is :: prohibited to be used with decltype? If so, what's the best   
   > workaround? Just pass decltype to an intermediary template like so?   
      
   I just notice that I forgot to respond to your last question in my   
   previous reply: The most simple workaround for a defective compiler   
   should be to split the declaration of x into two parts:   
      
   std::vector vec;   
   typedef decltype(vec) c_t;   
   c_t::value_type x;   
      
   This should work.   
      
   > foo::value_type   
   >   
   > Seems kind of inconvenient if that is the case...   
      
   I agree and it should not be necessary to introduce an additional type   
   layer (like foo) for this simple request.   
      
   If the two-step declaration is no good workaround for you, you should   
   consider to switch to gcc 4.7.   
      
   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)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca