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 31,515 of 33,346   
   Dave Abrahams to All   
   Re: what combination of type_traits to d   
   01 Oct 11 15:37:06   
   
   cdd70681   
   From: dave@boostpro.com   
      
   on Sat Oct 01 2011, Ken  wrote:   
      
   > Hi,   
   >   
   > I need to allocate an array of 100mln small objects Foo dynamically at   
   > once.   
   >   
   > I have no issues telling std::vector how many I want, but I really   
   > don't want to call Foo() 100mln times (default constructor does   
   > nothing - would be fine if the objects were zero'ed out).   
   >   
   > If Foo is a POD and I know that zero-initialization is ok, I can use   
   > calloc() to allocate my array and free() it later.  Unfortunately   
   > is_pod() is a little too restrictive - Foo is rather simple, but by   
   > just having any constructor, it is no longer POD (I need some non-   
   > default constructors for convenience).   
      
   I think you want has_trivial_default_constructor<>   
      
   HTH,   
      
   --   
   Dave Abrahams   
   BoostPro Computing   
   http://www.boostpro.com   
      
      
         [ 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