Allow comparing rcp<T> to rcp<U>

This commit is contained in:
josh committed 2026-02-24 17:10:01 -05:00
1 parent 11555ded36
commit 69ecab39f2
2 files changed
+18 -4

No files matched your search

+12
View File
@@ -181,6 +181,17 @@ void test_move_assignment_releases_existing()
assert(mybase_destruct == destructed_before + 2);
}
void test_cross_type_comparison()
{
rcp<MyDerived> derived = MyDerived::create(1.5);
rcp<MyBase> base = derived;
assert(base == derived);
assert(!(base != derived));
rcp<MyBase> other = MyBase::create(1, 2);
assert(base != other);
assert(!(base == other));
}
void test_reset()
{
int destructed_before = mybase_destruct;
@@ -238,6 +249,7 @@ int main(int argc, char * argv[])
test_create();
test_multi_construct_from_raw_pointers();
test_copy_assignment_decrements_previous_reference();
test_cross_type_comparison();
test_reset();
test_move_constructor();
test_move_assignment();