Which smart pointer should I use?
<p>I'm woring against a model which consists of a number of different types (Properties, Parent, Child, etc). Each type is associated with a set of functions from a c api. For example:</p>

<pre><code>Type "Properties":
  char* getName(PropertiesHandle);
  char* getDescription(PropertiesHandle);

Type "Parent"
  PropertiesHandle getProperties(ParentHandle);
  ChildHanlde getFirstChild(ParentHandle);

Type "Child"
  PropertiesHandle getProperties(ChildHandle);
  ParentHanlde getParent(ChildHandle);
  ChildHandle getNextChild(ChildHandle);
</code></pre>

<p>I have in turn created a set of C++ interfaces for this c api library, as follows:</p>

<pre><code>class IProperties
{
public:
  virtual std::string getName() = 0;
  virtual std::string getDescription() = 0;
};

class IParent
{
public:
  virtual std::shared_ptr&lt;IProperties&gt; getProperties() = 0;
  virtual std::shared_ptr&lt;IChild&gt; getFirstChild() = 0;
};

class IChild
{
public:
  virtual std::shared_ptr&lt;IProperties&gt; getProperties() = 0;
  virtual std::shared_ptr&lt;IParent&gt; getParent() = 0;
  virtual std::shared_ptr&lt;IChild&gt; getNextChild() = 0;
};
</code></pre>

<p>I then implement these interfaces via the classes Properties, Parent and Child.</p>

<p>So a Child instance will take its specific ChildHandle via its constructor and its getParent function will look something like this:</p>

<pre><code>std::shared_ptr&lt;IParent&gt; getParent()
{
    // get the parent handle and wrap it in a Parent object
    return std::shared_ptr&lt;IParent&gt;(new Parent(_c_api-&gt;getParent(_handle)));
}
</code></pre>

<p>Is it reasonable for me to return a shared_ptr here in your opinion. I cant use std::unique_ptr since Google Mock requires parameters and return values of mocked methods to be copyable. I'm mocking these interfaces in my tests via Google Mock. </p>

<p>I'm thinking also about how things might get optimized in the future which might present the possibly of circular references. This could be caused if caching is used to avoid multiple calls to the C api (for example, no need for a child to establish its parent more than once) combined with say the Child constructor taking its Parent. This would then require the use of weak_ptrs which would change the interfaces and a lot of my code...</p>
