How do I create a duplicate instance of object contained in a shared pointer in c++? -


I have an object on which a copy constructor and assignment operator is defined. It is attached inside a shared indicator.

I want to create a shared sharing indicator that has a copy of the original shared pointers (i.e. the new shared pointer for the new shared space, however, the same data as the original object).

Thank you for any help.

You are creating new objects per constructor:

  std :: shared_ptr & lt; C & gt; Ptr1 (new C) // default constructor std :: shared_ptr & lt; C & gt; Ptr2 (new c (* ptr1)); // This CoP invokes the constructor  

In this case, if you have a regular, dumb signal then it is not really different.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -