diff --git a/include/rcp.h b/include/rcp.h index a670d45..d49a156 100644 --- a/include/rcp.h +++ b/include/rcp.h @@ -224,6 +224,18 @@ public: friend rcp rcp_dynamic_cast(rcp && other); }; +template +bool operator==(std::nullptr_t, const rcp & p) +{ + return p == nullptr; +} + +template +bool operator!=(std::nullptr_t, const rcp & p) +{ + return p != nullptr; +} + namespace std { template diff --git a/tests.cpp b/tests.cpp index 2bc0a43..6bd55a3 100644 --- a/tests.cpp +++ b/tests.cpp @@ -84,6 +84,8 @@ void test_booleans() rcp myderived; assert(!myderived); assert(myderived == nullptr); + assert(nullptr != mybase); + assert(nullptr == myderived); } void test_create()