Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In the first case, you add a level of indirection to the <em>pointer</em>, such that the object that is represented by the smart pointer wraps the original pointer. There is only one pointer to the object and it's the wrapper's job to keep track of the references to the original pointer. A very simplistic bit of code might look like this:</p> <pre><code>template&lt;typename T&gt; struct smart_ptr { T *ptr_to_object; int *ptr_to_ref_count; }; </code></pre> <p>When you copy the struct, your copy/assign code will have to make sure that the reference count is incremented (or decremented if the object gets destroyed) but the pointer to the actual wrapped object will never change and can just be shallow copied. As the struct is pretty small, it's easy and cheap to copy and "all" you have to do is to manipulate the reference count.</p> <p>In the second case, it reads to me more like an object repository. The 'implicitly shared' part suggests that you might ask the framework for a <code>FooWidget</code> by doing something like <code>BarFoo.getFooWidget()</code> and even though it looks like the pointer - smart or not - that you get back is a pointer to a new object, you're actually being handed a pointer to an existing object that's held in some sort of object cache. In that sense it might be more akin to a Singleton-like object that you get by invoking a factory method.</p> <p>At least that's what the distinction sounds like to me, but I might be so far off the mark that I'd need Google Maps to find my way back.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload