lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [5508] Improve copy ctor and assignment and equality opera


From: Greg Chicares
Subject: [lmi-commits] [5508] Improve copy ctor and assignment and equality operators
Date: Sun, 24 Jun 2012 00:27:17 +0000

Revision: 5508
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5508
Author:   chicares
Date:     2012-06-24 00:27:17 +0000 (Sun, 24 Jun 2012)
Log Message:
-----------
Improve copy ctor and assignment and equality operators

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/mec_input.cpp
    lmi/trunk/mec_state.cpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2012-06-23 22:34:17 UTC (rev 5507)
+++ lmi/trunk/ChangeLog 2012-06-24 00:27:17 UTC (rev 5508)
@@ -30366,3 +30366,9 @@
 Improve copy ctor and assignment and equality operators (VS). See:
   http://lists.nongnu.org/archive/html/lmi/2012-03/msg00014.html
 
+20120624T0027Z <address@hidden> [573]
+
+  mec_input.cpp
+  mec_state.cpp
+Improve copy ctor and assignment and equality operators.
+

Modified: lmi/trunk/mec_input.cpp
===================================================================
--- lmi/trunk/mec_input.cpp     2012-06-23 22:34:17 UTC (rev 5507)
+++ lmi/trunk/mec_input.cpp     2012-06-24 00:27:17 UTC (rev 5508)
@@ -126,14 +126,7 @@
     ,MemberSymbolTable <mec_input>()
 {
     AscribeMembers();
-    std::vector<std::string>::const_iterator i;
-    for(i = member_names().begin(); i != member_names().end(); ++i)
-        {
-        // This would be wrong:
-        //   operator[](*i) = z[*i];
-        // because it would swap in a copy of z's *members*.
-        operator[](*i) = z[*i].str();
-        }
+    MemberSymbolTable<mec_input>::assign(z);
     DoAdaptExternalities();
 }
 
@@ -143,28 +136,14 @@
 
 mec_input& mec_input::operator=(mec_input const& z)
 {
-    std::vector<std::string>::const_iterator i;
-    for(i = member_names().begin(); i != member_names().end(); ++i)
-        {
-        operator[](*i) = z[*i].str();
-        }
+    MemberSymbolTable<mec_input>::assign(z);
     DoAdaptExternalities();
     return *this;
 }
 
 bool mec_input::operator==(mec_input const& z) const
 {
-    std::vector<std::string>::const_iterator i;
-    for(i = member_names().begin(); i != member_names().end(); ++i)
-        {
-        std::string const s0 = operator[](*i).str();
-        std::string const s1 = z[*i].str();
-        if(s0 != s1)
-            {
-            return false;
-            }
-        }
-    return true;
+    return MemberSymbolTable<mec_input>::equals(z);
 }
 
 int mec_input::maturity_age() const {return GleanedMaturityAge_;}

Modified: lmi/trunk/mec_state.cpp
===================================================================
--- lmi/trunk/mec_state.cpp     2012-06-23 22:34:17 UTC (rev 5507)
+++ lmi/trunk/mec_state.cpp     2012-06-24 00:27:17 UTC (rev 5508)
@@ -61,14 +61,7 @@
     ,MemberSymbolTable <mec_state>()
 {
     AscribeMembers();
-    std::vector<std::string>::const_iterator i;
-    for(i = member_names().begin(); i != member_names().end(); ++i)
-        {
-        // This would be wrong:
-        //   operator[](*i) = z[*i];
-        // because it would swap in a copy of z's *members*.
-        operator[](*i) = z[*i].str();
-        }
+    MemberSymbolTable<mec_state>::assign(z);
 }
 
 mec_state::~mec_state()
@@ -77,27 +70,13 @@
 
 mec_state& mec_state::operator=(mec_state const& z)
 {
-    std::vector<std::string>::const_iterator i;
-    for(i = member_names().begin(); i != member_names().end(); ++i)
-        {
-        operator[](*i) = z[*i].str();
-        }
+    MemberSymbolTable<mec_state>::assign(z);
     return *this;
 }
 
 bool mec_state::operator==(mec_state const& z) const
 {
-    std::vector<std::string>::const_iterator i;
-    for(i = member_names().begin(); i != member_names().end(); ++i)
-        {
-        std::string const s0 = operator[](*i).str();
-        std::string const s1 = z[*i].str();
-        if(s0 != s1)
-            {
-            return false;
-            }
-        }
-    return true;
+    return MemberSymbolTable<mec_state>::equals(z);
 }
 
 namespace




reply via email to

[Prev in Thread] Current Thread [Next in Thread]