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,199 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to Jonathan Thornburg   
   Re: Initialization and trivial construct   
   26 Apr 12 14:15:16   
   
   From: daniel.kruegler@googlemail.com   
      
   On 2012-04-26 06:25, Jonathan Thornburg wrote:   
   > nroberts  wrote:   
   >> A pod structure cannot be initialized to anything   
   >> but 0 in the initializer list without a helper.   
   >   
   > I find this statement confusing.   
   > Notably, consider the following code:   
   >   
   >       #include   
   >   
   >       struct  pod   
   >               {   
   >               int x, y;   
   >               pod(int x_in): x(x_in), y(42) { }   
   >               };   
      
   Keep in mind that your type "pod" is not a POD type, because of the lack   
   of a (trivial) default constructor see Clause 9 p10:   
      
   "A POD struct is [..] a trivial class [..]"   
      
   and p.6:   
      
   "A trivial class is a class that has a trivial default constructor [..]"   
      
   But 'pod' does not have a default-constructor. Nonetheless C++11 has now   
   realized that pod is a standard_layout type.   
      
   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