Improve the implementation of CHECK() macro.

CHECK_EQ() currently does not work with smart pointers and nullptr.
This is an attempt to improve the situation by improving the
EagerEvaluator template. As a side benefit, the new implementation
no longer uses macros to generate template specializations.

The primary motivation of this change is to improve compatibility
with logging macros from google3 (Google's internal monorepo) and
make it easier to export code that was developed there to Android.

Bug: 151119760
Test: atest --host libbase_test

Change-Id: I9c957d5ddf2afb87a88304b1e4d7ceebea0fa2f8
diff --git a/logging_test.cpp b/logging_test.cpp
index 593e2c1..d8d0855 100644
--- a/logging_test.cpp
+++ b/logging_test.cpp
@@ -22,6 +22,7 @@
 #include <signal.h>
 #endif
 
+#include <memory>
 #include <regex>
 #include <string>
 #include <thread>
@@ -66,6 +67,16 @@
   ASSERT_DEATH({SuppressAbortUI(); CHECK_EQ(0, 1);}, "Check failed: 0 == 1 ");
   CHECK_EQ(0, 0);
 
+  std::unique_ptr<int> p;
+  ASSERT_DEATH(CHECK_NE(p, nullptr), "Check failed");
+  CHECK_EQ(p, nullptr);
+  CHECK_EQ(p, p);
+
+  const char* kText = "Some text";
+  ASSERT_DEATH(CHECK_NE(kText, kText), "Check failed");
+  ASSERT_DEATH(CHECK_EQ(kText, nullptr), "Check failed.*null");
+  CHECK_EQ(kText, kText);
+
   ASSERT_DEATH({SuppressAbortUI(); CHECK_STREQ("foo", "bar");},
                R"(Check failed: "foo" == "bar")");
   CHECK_STREQ("foo", "foo");
@@ -97,6 +108,13 @@
   }
   DCHECK_EQ(0, 0);
 
+  std::unique_ptr<int> p;
+  if (android::base::kEnableDChecks) {
+    ASSERT_DEATH(DCHECK_NE(p, nullptr), "DCheck failed");
+  }
+  DCHECK_EQ(p, nullptr);
+  DCHECK_EQ(p, p);
+
   if (android::base::kEnableDChecks) {
     ASSERT_DEATH({SuppressAbortUI(); DCHECK_STREQ("foo", "bar");},
                  R"(DCheck failed: "foo" == "bar")");