From: Jihoon Kim Date: Mon, 31 Jul 2017 07:10:45 +0000 (+0900) Subject: Add copy constructor X-Git-Tag: accepted/tizen/4.0/unified/20170816.012218^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F71%2F141371%2F1;p=platform%2Fcore%2Fuifw%2Fise-engine-sunpinyin.git Add copy constructor 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 --- diff --git a/src/portability.cpp b/src/portability.cpp index ea3b4fb..86fa6c2 100644 --- a/src/portability.cpp +++ b/src/portability.cpp @@ -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 { diff --git a/src/portability.h b/src/portability.h index 3307aff..04320e4 100644 --- a/src/portability.h +++ b/src/portability.h @@ -132,6 +132,9 @@ public: bool operator==(const TLongExpFloat& b) const; + TLongExpFloat& + operator=(const TLongExpFloat& b); + void toString(std::string& str) const; diff --git a/src/slm/slm.h b/src/slm/slm.h index 501146a..f626281 100644 --- a/src/slm/slm.h +++ b/src/slm/slm.h @@ -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;