From 771473b62a3371eade3ac5ceb5789a9f9d3b3393 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 25 Feb 2026 09:22:39 -0500 Subject: [PATCH] Rename template parameter to reduce chance of conflict --- include/rcp.h | 2 +- tests.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/rcp.h b/include/rcp.h index 5912a2a..896af56 100644 --- a/include/rcp.h +++ b/include/rcp.h @@ -292,7 +292,7 @@ rcp rcp_dynamic_cast(rcp && other) { \ return rcp_ref_count.load(std::memory_order_relaxed); \ } \ - template friend class rcp; \ + template friend class rcp; \ rcp_managed(classname) #define rcp_managed(classname) \ diff --git a/tests.cpp b/tests.cpp index 0f9d695..82159e5 100644 --- a/tests.cpp +++ b/tests.cpp @@ -413,6 +413,27 @@ void test_hash() assert(map.find(c) == map.end()); } +template +struct Box +{ + rcp_managed_root(Box); +protected: + Box(T v) : v(v) {} +public: + T v; +}; + +void test_class_template() +{ + auto a = Box::create(42); + auto b = Box::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; }