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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8acd4291c317f897,start X-Google-Attributes: gid103376,public X-Google-Thread: 109fba,8acd4291c317f897,start X-Google-Attributes: gid109fba,public From: herwin@gmu.edu (Harry Erwin) Subject: Safety of the Booch Ada 95 Components Date: 1999/12/10 Message-ID: <1e2lds4.7trgj21rgj9i0N%herwin@gmu.edu>#1/1 X-Deja-AN: 559023172 X-Server-Date: 10 Dec 1999 15:32:47 GMT Followup-To: comp.lang.ada Organization: HDE Associates Keywords: Exception, safety, neutrality, self-assignment User-Agent: MacSOUP/2.4.1 Reply-To: herwin@gmu.edu Newsgroups: comp.lang.ada,comp.lang.c++ Date: 1999-12-10T15:32:47+00:00 List-Id: In C++, the equate operation for a container class C is preferably defined as follows (Sutter, Exceptional C++, Addison-Wesley, 2000): template C& operator=(const C& c) { if(&c == this) return *this; // not required; done for efficiency C temp(c); // uses the copy constructor, may throw swap(temp, *this); // swaps the guts of this container with // temp. May not throw. return *this; // May not throw. } // the destructor for temp releases the memory originally in this // container, and destructors may not throw This is strongly exception-safe and exception-neutral, since only the copy constructor can throw, and that occurs before the guts are swapped. Hence the container remains useable, and no objects are lost from it. Now I've been looking at the Booch components for Ada 95, and have noticed that the Copy function typically starts by clearing the To container. That immediately implies that they are not exception-safe, but I'm concerned that they may not be safe under self-assignment as well. Is there something about the Ada 95 standard that guarantees that there will be no aliasing of container args? -- Harry Erwin, PhD,