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,689 of 33,346   
   noreply@firemath.info to All   
   constexpr and initializer_list which com   
   25 Nov 12 14:09:34   
   
   The following code compiles with gcc 4.7.1. Clang 3.1 reports an error   
   reading "constexpr variable 'x' must be initialized by a constant   
   expression".  The problem is independent of ini_list being passed by   
   const-ref or by value.   
      
   Which compiler conforms to the C++11 standard?   
      
   Thanks for your time.   
      
      
      
   #include    
   #include    
      
   struct foo   
   {   
      constexpr   
      foo( const std::initializer_list &ini_list ) : val(   
   *(ini_list.begin()) )   
      {}   
      const int val;   
   };   
      
   int main()   
   {   
      constexpr foo  x{ 4, 5 };   
      std::cout << x.val << "\n";   
   }   
      
      
   --   
         [ 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