f7136e64   
   From: moreno_news@mailinator.com   
      
   On 12-02-13 02:30 AM, Mathias Gaunard wrote:   
   > On Feb 12, 8:26 pm, Carlos Moreno wrote:   
   >> On 12-02-11 07:37 PM, Mathias Gaunard wrote:   
   >>   
   >>>> I've failed to   
   >>>> demonstrate that std::vector is faster than our internal one.   
   >>>> Unfortunately my profiling uniformly suggests std::vector is 10% slower,   
   >>   
   >>> That must mean that your custom vector class is not doing the same   
   >>> thing as std::vector, simply.   
   >>> For example std::vector initializes everything you put inside, which   
   >>> might not be your case. If your own vector doesn't initialize things,   
   >>> it also means it's unusable with types that are not PODs.   
   >>   
   >> Hopefully you meant the opposite   
   >   
   > I didn't.   
   >   
   > I don't understand what you're saying. POD stands for Plain Old Data,   
   > types that do not have custom constructors, destructors, nor   
   > assignment operators.   
   >   
   > If your code does not call constructors, as std::vector does, then it   
   > only works with POD types, and therefore is unusable with types that   
   > are not PODs.   
   >   
   > Bear in mind std::vector allocates memory then use placement new to   
   > copy-construct elements. It does not use 'new' nor default   
   > constructors (it does call it once when resizing/constructing if not   
   > given an explicit value, but only once and then copies).   
      
   I see what you mean --- but notice one key aspect of what I was   
   saying: std::vector does initialize built-ins, so one may grow   
   accustomed to relying on that (and take that guarantee as part   
   of our "minimum requirements"). In that sense is that I said that   
   for built-ins, a custom array class would be useless (in that one   
   would have to initialize things by hand if needed).   
      
   True that I was assuming the straightforward simple implementation   
   that uses new T[size] instead of allocating raw memory and using   
   placement new. In that context, user-defined types with a ctor   
   can not be uninitialized.   
      
   Carlos   
   --   
      
      
   --   
    [ 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)   
|