From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,48fa8e3cfaec41af X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-22 22:56:19 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: kcline17@hotmail.com (Kevin Cline) Newsgroups: comp.lang.ada Subject: Re: worth the hassle? Date: 22 Jul 2002 22:56:18 -0700 Organization: http://groups.google.com/ Message-ID: References: NNTP-Posting-Host: 192.76.70.227 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1027403778 8284 127.0.0.1 (23 Jul 2002 05:56:18 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 23 Jul 2002 05:56:18 GMT Xref: archiver1.google.com comp.lang.ada:27325 Date: 2002-07-23T05:56:18+00:00 List-Id: "Frank J. Lhota" wrote in message news:... > "Stephen Leake" wrote in message > news:uheirlk4z.fsf@gsfc.nasa.gov... > > My own opinion is that supporting limited types is a requirement for > > any general-purpose container. > > > > This is probably one reason why Ada will never be as popular as C++; > > in C++, you don't have to make this kind of decision :). > > Why isn't this a C++ issue as well? Certainly it is possible to declare the > C++ equivalent of a limited type, i.e. a type for which assignment is not > available. It is a C++ issue, but it is now fairly standard practice to write containers that only require the contained class to have a copy constructor. The STL is implemented in this way. The containers allocate raw memory, and use placement-new and explicit destructor calls to create and destroy objects, like this: char* mem = new char[sizeof T]; // get some memory T* t = new T(mem, *oldT); // copy-construct object on mem t->~T(); // destroy object Not the sort of thing one would want to see sprinkled through an application, but fine if encapsulated in a container class.