Working on an old project, I found some code that appears to be ASSERTing a class reference.
class classA
{
public:
...
classB myClassB;
};
classA::classA
{
ASSERT (myClassB);
}
I can't even get this syntax to compile in a brand new C++ project (VS2012).
We do have our own definition of ASSERT which goes
#define ASSERT(statement) \
if (!(statement)) \
{ \
logAssertion (TEXT(#statement), __FILE__, __LINE__); \
}
(The one in the MS includes (afh.h) looks like this)
#define ASSERT(f) DEBUG_ONLY((void) ((f) || !::AfxAssertFailedLine(THIS_FILE, __LINE__) || (AfxDebugBreak(), 0)))
classB is derived from CWnd, it seems to pass the ASSERT when its HWND is non NULL (this is just a guess, though that is the intention of the ASSERT in the old code). Is there an operator in the class that could be responsible for this sort of validity check?
Edit ---
In my old code .... if I assert on a CString it compiles, if I ASSERT on a primitive class like ClassA above it fails to compile on
error C2675: unary '!' : 'classA' does not define this operator or a conversion to a type acceptable to the predefined operator