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 ea3b4fbbc5f1121161858c75d980449506e7d7e7..86fa6c2787c80e0cf7a7937dbc5299d5659d7ca5 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 3307aff372c44532744d003c21b863de2c440cec..04320e4aa3fe85dd3b032e5be134ceb5537fe29e 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 501146a00788526c25d7732840360dfeb9a70661..f626281586e9065ad7ad556ad4bc04583aa2c2a2 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;