Add operator bool() and test boolean checks
This commit is contained in:
parent
be2da870bb
commit
ffe8433d55
@ -99,6 +99,11 @@ public:
|
||||
{
|
||||
return !ptr;
|
||||
}
|
||||
|
||||
operator bool() const
|
||||
{
|
||||
return ptr != nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
#define rcp_managed_root(classname) \
|
||||
|
||||
@ -69,9 +69,18 @@ void test_dereference()
|
||||
assert((*mybase).y == 3);
|
||||
}
|
||||
|
||||
void test_booleans()
|
||||
{
|
||||
rcp<MyBase> mybase = MyBase::create(2, 3);
|
||||
assert(mybase);
|
||||
rcp<MyDerived> myderived;
|
||||
assert(!myderived);
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
test_destructors_called();
|
||||
test_dereference();
|
||||
test_booleans();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user