Browse Source

[trac517] make RBTreeNodeChain non copyable

In the latest usage we don't need to copy RBTreeNodeChain objects.
It would be safer to disable copy unless/until we see need for it.
JINMEI Tatuya 14 years ago
parent
commit
c73a307cb4
1 changed files with 9 additions and 21 deletions
  1. 9 21
      src/lib/datasrc/rbtree.h

+ 9 - 21
src/lib/datasrc/rbtree.h

@@ -314,35 +314,23 @@ class RBTreeNodeChain {
 public:
     /// \name Constructors and Assignment Operator.
     ///
+    /// \note The copy constructor and the assignment operator are
+    /// intentionally defined as private, making this class non copyable.
+    /// This may have to be changed in a future version with newer need.
+    /// For now we explicitly disable copy to avoid accidental copy happens
+    /// unintentionally.
     //{@
     /// The default constructor.
     ///
     /// \exception None
     RBTreeNodeChain() : node_count_(0) {}
 
-    /// Copy constructor.
-    ///
-    /// \exception None
-    RBTreeNodeChain(const RBTreeNodeChain<T>& node_path) {
-        node_count_ = node_path.node_count_;
-        if (node_count_ > 0) {
-            memcpy(nodes_, node_path.nodes_, node_count_ * sizeof(RBNode<T>*));
-        }
-    }
-
-    /// Assignment operator.
-    ///
-    /// \exception None
-    RBTreeNodeChain<T>&
-    operator=(const RBTreeNodeChain<T>& node_path) {
-        node_count_ = node_path.node_count_;
-        if (node_count_ > 0) {
-            memcpy(nodes_, node_path.nodes_, node_count_ * sizeof(RBNode<T>*));
-        }
-        return (*this);
-    }
+private:
+    RBTreeNodeChain(const RBTreeNodeChain<T>&);
+    RBTreeNodeChain<T>& operator=(const RBTreeNodeChain<T>&);
     //@}
 
+public:
     /// \brief Return the number of levels stored in the chain.
     ///
     /// It's equal to the number of nodes in the chain; for an empty