[esnacc-dev] cxx/asnbufbits: constify operator<

Message ID 20190118155617.18174-1-aconole@bytheb.org
State New
Delegated to: Aaron Conole
Headers show

Commit Message

Aaron Conole Jan. 18, 2019, 3:56 p.m.
The less-than comparison operator makes no modifications to the internal
state of either the lhs or rhs of the expression.  Signal this properly
as a 'const' operation.

Signed-off-by: Aaron Conole <aconole@bytheb.org>
---
 cxx-lib/inc/asn-buf.h       | 2 +-
 cxx-lib/src/asn-bufbits.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Aaron Conole Jan. 18, 2019, 4:16 p.m. | #1
Aaron Conole <aconole@bytheb.org> writes:

> The less-than comparison operator makes no modifications to the internal
> state of either the lhs or rhs of the expression.  Signal this properly
> as a 'const' operation.
>
> Signed-off-by: Aaron Conole <aconole@bytheb.org>
> ---

Apologies for the spam on this one.  The list configuration had a loop,
discovered after a restart.

Resolved now.

Patch

diff --git a/cxx-lib/inc/asn-buf.h b/cxx-lib/inc/asn-buf.h
index 013e3d6..c2e7bd3 100644
--- a/cxx-lib/inc/asn-buf.h
+++ b/cxx-lib/inc/asn-buf.h
@@ -216,7 +216,7 @@  public:
 	}
 */
 
-    bool operator<(AsnBufBits &rhs);
+    bool operator<(const AsnBufBits &rhs) const;
 
 	unsigned char MaskBits(unsigned char cCharToMask, int iBitsToMask);
 	unsigned long PutBits(const unsigned char* seg, unsigned long numBits);
diff --git a/cxx-lib/src/asn-bufbits.cpp b/cxx-lib/src/asn-bufbits.cpp
index 361d172..368f65c 100644
--- a/cxx-lib/src/asn-bufbits.cpp
+++ b/cxx-lib/src/asn-bufbits.cpp
@@ -627,7 +627,7 @@  unsigned char  AsnBufBits::MaskBits(unsigned char cCharToMask, int iBitsToMask)
 
 
 //RWC;TBD; FIX THIS TO WORK PROPERLY.....
-bool AsnBufBits::operator<(AsnBufBits &rhs)
+bool AsnBufBits::operator<(const AsnBufBits &rhs) const
 {
 	FUNC("AsnBufBits::operator<()");