Rename template parameter to reduce chance of conflict

This commit is contained in:
Josh Holtrop 2026-02-25 09:22:39 -05:00
parent 3a624ee65b
commit 771473b62a
2 changed files with 23 additions and 1 deletions

View File

@ -292,7 +292,7 @@ rcp<T> rcp_dynamic_cast(rcp<U> && other)
{ \
return rcp_ref_count.load(std::memory_order_relaxed); \
} \
template <typename T> friend class rcp; \
template <typename RCP_T_> friend class rcp; \
rcp_managed(classname)
#define rcp_managed(classname) \

View File

@ -413,6 +413,27 @@ void test_hash()
assert(map.find(c) == map.end());
}
template <typename T>
struct Box
{
rcp_managed_root(Box);
protected:
Box(T v) : v(v) {}
public:
T v;
};
void test_class_template()
{
auto a = Box<int>::create(42);
auto b = Box<int>::create(99);
assert(a->v == 42);
assert(b->v == 99);
auto c = a;
assert(c->v == 42);
assert(c.use_count() == 2);
}
void test_external_class()
{
int before = external_destruct;
@ -454,6 +475,7 @@ int main(int argc, char * argv[])
test_use_count();
test_swap();
test_hash();
test_class_template();
test_external_class();
return 0;
}