SOLVED IsEqual not defined

I get a compiler error, and can't seem to wrap my head around the actual problem
Say I have the following code (reduced to a dummy minimum for purpose of demonstration):


#include "c4d.h"

class Int32Pair
{
public:
	Int32Pair() : a(0), b(0) {}
	Int32Pair(const Int32& _a, const Int32& _b) : a(_a), b(_b) {}
	virtual ~Int32Pair() {}
private:
	Int32 a;
	Int32 b;
};

class Test
{
public:
	Test()
	{
		maxon::BaseArray<Int32Pair> somedata;
		if (somedata == mPairArray)
		{
			// do something
		}
	}

	~Test() {}

private:
	maxon::BaseArray<Int32Pair> mPairArray;
};

Basically, I have two arrays of Int32Pair which I want to compare, but compiler gives me a

error C2338: IsEqual not defined.

Which I have narrowed done as being caused by the line

if (somedata == mPairArray)

Where should this IsEqualbe defined?

Inspired by the SortedArray example I tried adding an IsEqual into the Int32Pair class as:

static maxon::Bool IsEqual(const Int32Pair& p1, const Int32Pair& p2) { return (p1.a == p2.a) && (p1.b == p2.b); }

But compiler still complains about IsEqual not being defined.
As such, I am guessing it's the BaseArray which needs to be defined with a compare method. But how? Have tried looking into the BaseArray manual, but failed to find any answer.

I would appreciate an example showing how it needs to be done. Thanks in advance.

Hello,

you have to define the operator == in your class Int32pair.
For this you have a macro that help, it will implement both == and != operator.

class Int32Pair
{
public:
	Int32Pair() : a(0), b(0) {}
	Int32Pair(const Int32& _a, const Int32& _b) : a(_a), b(_b) {}
	virtual ~Int32Pair() {}
	
	MAXON_OPERATOR_EQUALITY(Int32Pair, a, b);


private:
	Int32 a;
	Int32 b;


};

Let me know if it solve the problem 🙂

Cheers
Manuel

@m_magalhaes said in IsEqual not defined:

MAXON_OPERATOR_EQUALITY(Int32Pair, a, b);

Thanks, didn't know about the MAXON_OPERATOR_EQUALITY. Very handy indeed.

However, I had already tried providing an equality operator in my Int32Pair class, as such:

Bool operator == (const Int32Pair& other) { return (a == other.a) && (b == other.b); }

But that still resulted in the "IsEqual not defined" compiler error.
The macro, however, is working fine.

Looking further at my implementation of operator==, I now notice I didn't declare it as a const method. Adding the const does get rid of the compiler error. Oh boy! Overlooked a minor "typo", with major consequences.

Again, thanks for the macro.