This is the complete code. It is part of my home-made unit-test framework.
#include <iostream>
#define IS(arg1, arg2) is(arg1, arg2, #arg1 " == " #arg2)
template<typename T1, typename T2>
void is(T1 value, T2 expect, const char* desc)
{
if (value == expect)
{
std::cout << "ok " << " - " << desc << std::endl;
}
else
{
std::cout << "NOT ok " << " - " << desc << std::endl
<<" got " << value <<", expect "<< expect << " " << std::endl;
}
}
struct Foo
{};
int main(int argc, char** argv)
{
Foo* foo = 0;
IS(foo, 0);
}
The compiler would claim:
test.cpp:8:15: error: comparison between pointer and integer ('Foo *' and 'int')
if (value == expect)
~~~~~ ^ ~~~~~~
Is it because the actual comparison is happened between pointer and int variable?