diff --git a/include/rcp.h b/include/rcp.h index e0d9bf5..257186c 100644 --- a/include/rcp.h +++ b/include/rcp.h @@ -104,6 +104,12 @@ public: { return ptr != nullptr; } + + template + static rcp create(Args&&... args) + { + return T::create(std::forward(args)...); + } }; #define rcp_managed_root(classname) \ diff --git a/test/tests.cpp b/test/tests.cpp index f0e348f..90a29f3 100644 --- a/test/tests.cpp +++ b/test/tests.cpp @@ -77,10 +77,18 @@ void test_booleans() assert(!myderived); } +void test_create() +{ + typedef rcp MyB; + MyB myb = MyB::create(8, 9); + assert(myb->x == 8); +} + int main(int argc, char * argv[]) { test_destructors_called(); test_dereference(); test_booleans(); + test_create(); return 0; }