Merge pull request #51 from hzeller/no-const-on-integral-return-type
Don't use const for integral return types. It is confusing and doesn't
diff --git a/src/ErrorReporting/Error.cpp b/src/ErrorReporting/Error.cpp
index 715e803..4f73ccc 100644
--- a/src/ErrorReporting/Error.cpp
+++ b/src/ErrorReporting/Error.cpp
@@ -46,16 +46,14 @@
for (auto loc : (locations)) m_locations.push_back(loc);
}
-bool Error::operator==(Error& rhs) {
+bool Error::operator==(const Error& rhs) const {
if (m_errorId != rhs.m_errorId) return false;
- bool is_equal = false;
if (m_locations.size() < rhs.m_locations.size())
- is_equal = std::equal(m_locations.begin(), m_locations.end(),
- rhs.m_locations.begin());
+ return std::equal(m_locations.begin(), m_locations.end(),
+ rhs.m_locations.begin());
else
- is_equal = std::equal(rhs.m_locations.begin(), rhs.m_locations.end(),
- m_locations.begin());
- return is_equal;
+ return std::equal(rhs.m_locations.begin(), rhs.m_locations.end(),
+ m_locations.begin());
}
bool Error::operator<(const Error& rhs) const {
diff --git a/src/ErrorReporting/Error.h b/src/ErrorReporting/Error.h
index 7b58034..87d0ada 100644
--- a/src/ErrorReporting/Error.h
+++ b/src/ErrorReporting/Error.h
@@ -39,7 +39,7 @@
std::vector<Location>* extraLocs = NULL);
Error(ErrorDefinition::ErrorType errorId, Location& loc, Location& extra);
Error(ErrorDefinition::ErrorType errorId, std::vector<Location>& locations);
- bool operator==(Error& rhs);
+ bool operator==(const Error& rhs) const;
bool operator<(const Error& rhs) const;
struct compare {
bool operator()(const Error& e1, const Error& e2) const { return e1 < e2; }
diff --git a/src/ErrorReporting/Location.cpp b/src/ErrorReporting/Location.cpp
index 4f0e076..c884a33 100644
--- a/src/ErrorReporting/Location.cpp
+++ b/src/ErrorReporting/Location.cpp
@@ -27,7 +27,7 @@
Location::~Location() {}
-bool Location::operator==(Location& rhs) {
+bool Location::operator==(const Location& rhs) const {
if (m_fileId != rhs.m_fileId) return false;
if (m_line != rhs.m_line) return false;
if (m_column != rhs.m_column) return false;
diff --git a/src/ErrorReporting/Location.h b/src/ErrorReporting/Location.h
index f177ea7..8981136 100644
--- a/src/ErrorReporting/Location.h
+++ b/src/ErrorReporting/Location.h
@@ -37,7 +37,7 @@
: m_fileId(fileId), m_line(line), m_column(column), m_object(object){};
/* Do not create a copy constructor, use default*/
// Location(const Location& orig);
- bool operator==(Location& rhs);
+ bool operator==(const Location& rhs) const;
bool operator<(const Location& rhs) const;
virtual ~Location();
SymbolId m_fileId;