Jerome Posted January 12 Report Share Posted January 12 A *item = A::type_id::create("item", this); I am curious about the difference from systemverilog? should I delete item by myself, or will uvm systemc lib totally take over it? Quote Link to comment Share on other sites More sharing options...
Jerome Posted January 12 Author Report Share Posted January 12 "take care" , sorry for the typo Quote Link to comment Share on other sites More sharing options...
Eyck Posted January 12 Report Share Posted January 12 You need to take care yourself as the factory just calls new and returns a raw pointer. You should use a std::unique_ptr to hold the raw pointer: #include <memory> std::unique_ptr<A> a{A::type_id::create("item", this)}; or if you have to keep declaration and initialization separate: #include <memory> std::unique_ptr<A> a; a.reset(A::type_id::create("item", this)); This way C++ takes care of destruction properly Quote Link to comment Share on other sites More sharing options...
Jerome Posted January 12 Author Report Share Posted January 12 your reply is very helpful. 1 hour ago, Eyck said: You need to take care yourself as the factory just calls new and returns a raw pointer. You should use a std::unique_ptr to hold the raw pointer: #include <memory> std::unique_ptr<A> a{A::type_id::create("item", this)}; or if you have to keep declaration and initialization separate: #include <memory> std::unique_ptr<A> a; a.reset(A::type_id::create("item", this)); This way C++ takes care of destruction properly Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.