adamdebreceni commented on a change in pull request #887:
URL: https://github.com/apache/nifi-minifi-cpp/pull/887#discussion_r481949364



##########
File path: libminifi/include/utils/GeneralUtils.h
##########
@@ -68,6 +68,21 @@ using void_t = void;
 using std::void_t;
 #endif /* < C++17 */
 
+namespace internal {
+
+struct safe_enable_shared_from_this_base : 
std::enable_shared_from_this<safe_enable_shared_from_this_base> {

Review comment:
       we have to have a single class template instance 
`std::enable_shared_from_this<T>` for some type `T`, so that when we inherit 
from it virtually multiple times, we get the same `std::weak_ptr` instance
   
   for example in the following, if `U` depends on `T` we don't inherit from 
the same `enable_shared_from_this` class instance, but `U` also must be a base 
class of `T`, moreover it has to be polymorphic to `dynamic_cast` it to the 
derived type (that is why it has a virtual destructor)
   ```
   template<typename T>
   struct safe_enable_shared_from_this : virtual 
std::enable_shared_from_this<U> {...}
   
   struct A : safe_enable_shared_from_this<A> {...}
   struct B: A, safe_enable_shared_from_this<B>{...}
   ```
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to