I have this line in my code:
CHECK_EQ(MallocHook::SetNewHook(&NewHook), nullptr);
MallocHook::SetNewHook returns a pointer. I want to make sure it is null.
The above check passes on Release build but fails on Debug build:
../../base/logging.h: In instantiation of 'std::string* logging::MakeCheckOpString(const t1&, const t2&, const char*) [with t1 = void (*)(const void*, long unsigned int); t2 = std::nullptr_t; std::string = std::basic_string<char>]':
../../base/logging.h:540:1: required from 'std::string* logging::CheckEQImpl(const t1&, const t2&, const char*) [with t1 = void (*)(const void*, long unsigned int); t2 = std::nullptr_t; std::string = std::basic_string<char>]'
../../components/metrics/leak_detector/leak_detector.cc:239:3: required from here
../../base/logging.h:503:40: error: ambiguous overload for 'operator<<' (operand types are 'std::basic_ostream<char>' and 'std::nullptr_t')
ss << names << " (" << v1 << " vs. " << v2 << ")";
^
I searched through the Chrome code but couldn't find any other examples where nullptr was used in CHECK_EQ.
I suppose I could revise that line to:
CHECK(!MallocHook::SetNewHook(&NewHook))
But I'm wondering if there's an actual way to do a nullptr CHECK_EQ like that.
Simon