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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d2f0af5e440b367f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-07 08:36:14 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: proposal for new assignment operators Date: 7 Jul 2003 08:36:13 -0700 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0307070736.2eb5e820@posting.google.com> References: <3EF9CD5F.6030608@cogeco.ca> <3doRhIgUmUYX@eisner.encompasserve.org> <3F038B77.2F2E41B7@adaworks.com> NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1057592174 27186 127.0.0.1 (7 Jul 2003 15:36:14 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 7 Jul 2003 15:36:14 GMT Xref: archiver1.google.com comp.lang.ada:40107 Date: 2003-07-07T15:36:14+00:00 List-Id: Richard Riehle wrote in message news:<3F038B77.2F2E41B7@adaworks.com>... > > One reason for the peculiarity is that Ada, unlike C++, has limited > types. For limited types, assignment is never possible. Therefore, > overloading assignment is not possible. Limited types are used for > most container classes. The statement that C++ doesn't have limited types is false. To make a limited type in C++, you simply have to declare the assignment operator and copy constructor as private, and not define them: class Limited_Type is public: void f(); private: Limited_Type& operator=(const Limited_Type&); Limited_Type(const Limited_Type&); }; Also, most container types are not limited, because containers that are limited are hard to compose. (It should be easy to instantiate a container type using another container type as the element type.) The reason you need non-limited types is for composition, not for assignment (which has dubious value for a container). There are many ways to copy a container without using the assignment operator. Also, the assignment operator only allows you to copy from the same type, but it's often the case that the source or target of the assignment is some other kind of container (e.g. an array). > It is rare that one even needs to override the assignment operator > on a non-limited type. There is a distinction here that will not > be immediately obvious to the C++ programmer. You almost always need to override the assignment operator for a non-limited type, if the type allocates internal storage from a pool.