title: How much is the overhead of smart pointers compared to normal pointers in C++?
body: <p>How much is the overhead of smart pointers compared to normal pointers in C++11? In other words, is my code going to be slower if I use smart pointers, and if so, how much slower?</p>
  
  <p>Specifically, I'm asking about the C++11 <code>std::shared_ptr</code> and <code>std::unique_ptr</code>.</p>
  
  <p><em>Obviously, the stuff pushed down the stack is going to be larger (at least I think so), because a smart pointer also needs to store its internal state (reference count, etc), the question really is, how much is this going to affect my performance, if at all?</em></p>
  
  <p>For example, I return a smart pointer from a function instead of a normal pointer:</p>
  
  <pre><code>std::shared_ptr&lt;const Value&gt; getValue();
  // versus
  const Value *getValue();
  </code></pre>
  
  <p>Or, for example, when one of my functions accept a smart pointer as parameter instead of a normal pointer:</p>
  
  <pre><code>void setValue(std::shared_ptr&lt;const Value&gt; val);
  // versus
  void setValue(const Value *val);
  </code></pre>