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.h
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.h')
-rw-r--r--mert/Point.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/mert/Point.h b/mert/Point.h
index 9bfaff156..44070f72b 100644
--- a/mert/Point.h
+++ b/mert/Point.h
@@ -77,9 +77,9 @@ public:
// Compute the feature function
double operator*(const FeatureStats&) const;
- Point operator+(const Point&) const;
+ const Point operator+(const Point&) const;
void operator+=(const Point&);
- Point operator*(float) const;
+ const Point operator*(float) const;
/**
* Write the Whole featureweight to a stream (ie m_pdim float).