[PPL-devel] [GIT] ppl/ppl(pip): Clarified proper usage of PIP_Solution_Node alternative copy constructor.

Enea Zaffanella zaffanella at cs.unipr.it
Sat Feb 6 14:38:26 CET 2010


Module: ppl/ppl
Branch: pip
Commit: 51e0707e9e734ceb72382bf004e69a1076ec46c2
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=51e0707e9e734ceb72382bf004e69a1076ec46c2

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Fri Feb  5 19:02:44 2010 +0100

Clarified proper usage of PIP_Solution_Node alternative copy constructor.
The Boolean argument replaced by a tag struct type, since it was only used
for overloading resolution purposes.

---

 src/PIP_Tree.cc      |    8 ++------
 src/PIP_Tree.defs.hh |   12 ++++++++----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc
index cb62db1..b179e00 100644
--- a/src/PIP_Tree.cc
+++ b/src/PIP_Tree.cc
@@ -365,7 +365,7 @@ PIP_Solution_Node::PIP_Solution_Node(const PIP_Solution_Node& y)
 }
 
 PIP_Solution_Node::PIP_Solution_Node(const PIP_Solution_Node& y,
-                                     bool empty_constraints)
+                                     No_Constraints)
   : PIP_Tree_Node(),
     tableau(y.tableau),
     basis(y.basis),
@@ -377,10 +377,6 @@ PIP_Solution_Node::PIP_Solution_Node(const PIP_Solution_Node& y,
     sign(y.sign),
     solution(y.solution),
     solution_valid(y.solution_valid) {
-  if (!empty_constraints) {
-    constraints_ = y.constraints_;
-    artificial_parameters = y.artificial_parameters;
-  }
 }
 
 PIP_Decision_Node::PIP_Decision_Node(PIP_Tree_Node* fcp,
@@ -1887,7 +1883,7 @@ PIP_Solution_Node::solve(const PIP_Problem& problem,
 
       // Create a solution node for the "true" version of current node.
       // FIXME: this is not exception safe.
-      PIP_Tree_Node* t_node = new PIP_Solution_Node(*this, true);
+      PIP_Tree_Node* t_node = new PIP_Solution_Node(*this, No_Constraints());
       context.add_row(t_test);
 
       // Recusively solve true node.
diff --git a/src/PIP_Tree.defs.hh b/src/PIP_Tree.defs.hh
index 4190f55..b1a233f 100644
--- a/src/PIP_Tree.defs.hh
+++ b/src/PIP_Tree.defs.hh
@@ -514,11 +514,15 @@ protected:
   //! Copy constructor.
   PIP_Solution_Node(const PIP_Solution_Node& y);
 
-  /*! \brief
-    Copy constructor, allowing not to copy the constraint system and
-    artificial parameters
+  //! A tag type to select the alternative copy constructor.
+  struct No_Constraints {};
+
+  //! Alternative copy constructor.
+  /*!
+    This constructor differs from the default copy constructor in that
+    it will not copy the constraint system, nor the artificial parameters.
   */
-  PIP_Solution_Node(const PIP_Solution_Node& y, bool empty_constraints);
+  PIP_Solution_Node(const PIP_Solution_Node& y, No_Constraints);
 
   /*! \brief
     Populates the parametric simplex tableau using external data, if necessary




More information about the PPL-devel mailing list