- Where Developers Learn, Share, & Build Careers
I am working with a lot of interfaces for the purposes of dependency injection (test-driven development). For this reason, a lot of my objects are indicated through std :: shared_ptr. I could use std :: unique_ptr but when Google requires joke, they do not have a copy constructor.
Can they keep circular contexts with a view to the initial recognition if they exist?
I am working on a Linux platform with Google testing.
It is impossible to detect automatically circulated references with shared pointers, one The technique that I use to find circular references, it is clearly to do in the following ways: globally accessible In the promotion there is the definition of std :: vector & lt; T * & gt; , add the object to the vector in all the CTOs, and then remove it in the DTOors. Then at the end of the main you want to see that the vector is empty, if it is not, then you have a circular reference somewhere, and the vector will help you track down if you have points that are statically owned by the allocated objects So it is easy to walk in false positives, especially the static initial order failure is applied. BOOST_SP_ENABLE_DEBUG_HOOKS through which it is possible to expand this app for all types.
Comments
Post a Comment