title: C++: Smart Pointers & Fluent Design Pattern with References
body: <p>I'm trying to learn C++ after being spoiled with high-level languages for all of my life.</p>
  <p>I would like to use the <a href="https://en.wikipedia.org/wiki/Fluent_interface" rel="nofollow noreferrer">fluent design pattern</a> with a class, but I'm worried that I'm making a mistake somewhere and sacrificing performance.</p>
  <p>Say that I have a class <code>Builder</code>, and it has some member properties and methods. All of it's methods look something like so:</p>
  <pre><code>Builder &amp;doSomething(SomeTypeThatCouldBeAClassOrAPrimitive &amp;thing)
  {
      // do stuff, such as
      // modify a class member
      memberThing = &quot;something&quot;;
      
      return *thing;
  } 
  </code></pre>
  <p>And say that I'm using it like so:</p>
  <pre><code>unique_ptr&lt;Builder&gt; builder(new Builder());
  
  builder-&gt;doSomething(someVal)
          .doAnotherThing(someOtherVal)
          .doAFinalThing(someOtherOtherVal);
  </code></pre>
  <p>Just from the code provided, am I doing something wrong, or could something be done more efficiently?</p>
  <p>Please let me know if I need to provide more information.</p>