Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTetsuo Kiso <tetsuo-s@is.naist.jp>2012-04-12 04:16:27 +0400
committerTetsuo Kiso <tetsuo-s@is.naist.jp>2012-04-12 04:16:27 +0400
commit0e9b5fd9d0b7458a938a02fd73f23b07b462a3ba (patch)
tree89d55526b81cd54ed49f1e9ad07787f9594cc8c0 /mert/Point.cpp
parent366d427ce68e1cd922c0629667dc3ee05e8183c1 (diff)
Add const to return values of overloaded operators.
* This commit prevents developers from doing mistakes like: Point p1, p2, p4; if (p1 + p2 = p4) { // Bang! We actually wanted to compare // the result of two points: (p1 + p2 == p4). // do something. } See, e.g., http://www.gotw.ca/gotw/006.htm for details. * Add more test cases according to this change. * Move a helper function to compare floating point numbers to Util.h.
Diffstat (limited to 'mert/Point.cpp')
-rw-r--r--mert/Point.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/mert/Point.cpp b/mert/Point.cpp
index 6be8ef31f..085c71339 100644
--- a/mert/Point.cpp
+++ b/mert/Point.cpp
@@ -76,7 +76,7 @@ double Point::operator*(const FeatureStats& F) const
return prod;
}
-Point Point::operator+(const Point& p2) const
+const Point Point::operator+(const Point& p2) const
{
CHECK(p2.size() == size());
Point Res(*this);
@@ -97,7 +97,7 @@ void Point::operator+=(const Point& p2)
m_score = kMaxFloat;
}
-Point Point::operator*(float l) const
+const Point Point::operator*(float l) const
{
Point Res(*this);
for (unsigned i = 0; i < size(); i++) {