Add copy constructor 71/141371/1 accepted/tizen/4.0/unified/20170816.012218 accepted/tizen/4.0/unified/20170816.015843 accepted/tizen/4.0/unified/20170829.020027 accepted/tizen/unified/20170801.054955 submit/tizen/20170731.100903 submit/tizen_4.0/20170811.094300 submit/tizen_4.0/20170814.115522 submit/tizen_4.0/20170828.100004 submit/tizen_4.0_unified/20170814.115522
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 31 Jul 2017 07:10:45 +0000 (16:10 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 31 Jul 2017 07:10:47 +0000 (16:10 +0900)
The 'TLongExpFloat' class implements a copy constructor, but lacks the '=' operator. It is dangerous to use such a class.
The 'TState' class implements a copy constructor, but lacks the '=' operator. It is dangerous to use such a class.

Change-Id: I818c8b33eecdddc23654a857926817d937ec8064
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/portability.cpp
src/portability.h
src/slm/slm.h

index ea3b4fb..86fa6c2 100644 (file)
@@ -110,6 +110,18 @@ TLongExpFloat::operator==(const TLongExpFloat& b) const
     return(m_base == b.m_base && m_exp == b.m_exp);
 }
 
+TLongExpFloat&
+TLongExpFloat::operator=(const TLongExpFloat& b)
+{
+    if (m_base == b.m_base && m_exp == b.m_exp)
+        return *this;
+
+    m_base = b.m_base;
+    m_exp = b.m_exp;
+
+    return *this;
+}
+
 void
 TLongExpFloat::toString(std::string& str) const
 {
index 3307aff..04320e4 100644 (file)
@@ -132,6 +132,9 @@ public:
     bool
     operator==(const TLongExpFloat& b) const;
 
+    TLongExpFloat&
+    operator=(const TLongExpFloat& b);
+
     void
     toString(std::string& str) const;
 
index 501146a..f626281 100644 (file)
@@ -106,6 +106,13 @@ public:
         bool operator<(const TState & b) const {
             return unsigned(*this) < unsigned(b);
         }
+        TState& operator=(const TState& b) {
+            if (m_all == b.m_all)
+                return *this;
+
+            m_all = b.m_all;
+            return *this;
+        }
 
 private:
         unsigned int m_all;