Some of the Object::equals now are const correct.

There's more to do.

Why make this const-correct, instead of ditch it?  Because whatever
I replace it with has to be ready for const correctness.
This commit is contained in:
2025-08-22 13:58:05 -04:00
parent f6841f59e0
commit e4f1102e32
8 changed files with 38 additions and 32 deletions

View File

@ -4,6 +4,8 @@
#include <stdlib.h>
#include <string.h>
#include <utility>
#include "misc.hh"
namespace lout {
@ -25,7 +27,8 @@ class Object
{
public:
virtual ~Object();
virtual bool equals(Object *other);
virtual bool equals(const Object *other) const;
virtual bool equals(Object *other) final { return equals( &std::as_const( *other ) ); }
virtual int hashValue();
virtual Object *clone();
virtual void intoStringBuffer(misc::StringBuffer *sb) const;
@ -103,7 +106,7 @@ private:
public:
Pointer(void *value) { this->value = value; }
bool equals(Object *other);
bool equals(const Object *other) const override;
int hashValue();
void intoStringBuffer(misc::StringBuffer *sb);
inline void *getValue() { return value; }
@ -129,7 +132,7 @@ class Integer: public Comparable
public:
Integer(int value) { this->value = value; }
bool equals(Object *other);
bool equals(const Object *other) const override;
int hashValue();
void intoStringBuffer(misc::StringBuffer *sb);
int compareTo(Comparable *other);
@ -146,7 +149,7 @@ class Boolean: public Comparable
public:
Boolean(bool value) { this->value = value; }
bool equals(Object *other);
bool equals(const Object *other) const override;
int hashValue();
void intoStringBuffer(misc::StringBuffer *sb);
int compareTo(Comparable *other);
@ -166,7 +169,7 @@ protected:
public:
ConstString(const char *str) { this->str = str; }
bool equals(Object *other);
bool equals(const Object *other) const override;
int hashValue();
int compareTo(Comparable *other);
void intoStringBuffer(misc::StringBuffer *sb);
@ -201,9 +204,9 @@ public:
PairBase(Object *first, Object *second);
~PairBase();
bool equals(Object *other);
bool equals(const Object *other) const override;
int hashValue();
void intoStringBuffer(misc::StringBuffer *sb);
void intoStringBuffer(misc::StringBuffer *sb) const override;
size_t sizeOf();
};