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,534 of 33,346   
   Martin B. to Dave Harris   
   std::vector for incomplete type (was: Re   
   04 Oct 11 11:44:10   
   
   From: 0xCDCDCDCD@gmx.at   
      
   On 03.10.2011 20:56, Dave Harris wrote:   
   > musiphil@bawi.org (Seungbeom Kim) wrote (abridged):   
   >> Then is new[]/delete[] your preferred choice?   
   >> What benefits does it bring, and why would you prefer it to   
   >> std::vector?   
   >   
   > As a petty example, you can't write:   
   >   
   >      #include   
   >      class MyData;   
   >      std::vector  vec;   
   >   
   > because it's undefined behaviour to instantiate a std::vector on a   
   > partial type. Where-as with my home-grown vector, I can. The standard   
   > reserves for itself lots of freedoms and those translate into   
   > restrictions for users.   
   >   
      
   a) If it's undefined behaviour, any implementation would be allowed to   
   *define* this behaviour of it's `vector` so that it would be possible to   
   use it this way. Correct? (I.e. is it possible to write a vector that   
   allows this?)   
      
   b) QOI   
      
   c) It seems to me that it's unfortunate that its [undefined] behaviour.   
   [unspecifed] would make more sense, or would it?   
      
   > The consequence is that I can't use std::vector in a header, (...)   
      
   See above.   
      
   > (...) I can't forward-declare std::vector<>   
   > itself, either.   
   >   
      
   Hmmm ... haven't some issues wrt. to forward declaring stuff   
   (templates?) been addresses in C++11?   
      
   cheers,   
   Martin   
      
      
   --   
         [ 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