From 4c0051d53336b641e0c3dbda32dc859b396ea206 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 19 Nov 2022 21:03:40 +0100 Subject: [PATCH] Add const attribute to several compare operators Signed-off-by: Stefan Weil --- src/ccstruct/points.h | 4 ++-- src/ccutil/params.h | 2 +- src/dict/dawg.h | 2 +- src/lstm/recodebeam.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ccstruct/points.h b/src/ccstruct/points.h index c8c46ad161..418031f227 100644 --- a/src/ccstruct/points.h +++ b/src/ccstruct/points.h @@ -269,11 +269,11 @@ class TESS_API FCOORD { bool normalise(); /// test equality - bool operator==(const FCOORD &other) { + bool operator==(const FCOORD &other) const { return xcoord == other.xcoord && ycoord == other.ycoord; } /// test inequality - bool operator!=(const FCOORD &other) { + bool operator!=(const FCOORD &other) const { return xcoord != other.xcoord || ycoord != other.ycoord; } /// rotate 90 deg anti diff --git a/src/ccutil/params.h b/src/ccutil/params.h index ba8043b56d..f514d8709c 100644 --- a/src/ccutil/params.h +++ b/src/ccutil/params.h @@ -253,7 +253,7 @@ class StringParam : public Param { bool empty() const { return value_.empty(); } - bool operator==(const std::string &other) { + bool operator==(const std::string &other) const { return value_ == other; } void operator=(const std::string &value) { diff --git a/src/dict/dawg.h b/src/dict/dawg.h index 05e7c5c59b..0869f68df4 100644 --- a/src/dict/dawg.h +++ b/src/dict/dawg.h @@ -361,7 +361,7 @@ struct DawgPosition { dawg_index(dawg_idx), punc_index(punc_idx), back_to_punc(backtopunc) {} - bool operator==(const DawgPosition &other) { + bool operator==(const DawgPosition &other) const { return dawg_index == other.dawg_index && dawg_ref == other.dawg_ref && punc_index == other.punc_index && punc_ref == other.punc_ref && back_to_punc == other.back_to_punc; diff --git a/src/lstm/recodebeam.cpp b/src/lstm/recodebeam.cpp index 0bf28dab1e..4b00166fbf 100644 --- a/src/lstm/recodebeam.cpp +++ b/src/lstm/recodebeam.cpp @@ -322,7 +322,7 @@ void RecodeBeamSearch::ExtractBestPathAsWords(const TBOX &line_box, } struct greater_than { - inline bool operator()(const RecodeNode *&node1, const RecodeNode *&node2) { + inline bool operator()(const RecodeNode *&node1, const RecodeNode *&node2) const { return (node1->score > node2->score); } };