title: Is there any advantage in using std::optional to avoid default arguments in a function?
body: <p>I'm porting code to C++17, trying to use the new features while possible.  One thing I like is the idea to use <a href="http://en.cppreference.com/w/cpp/utility/optional" rel="noreferrer"><code>std::optional</code></a> to return or not a value in a function that may fail in some conditions.</p>
  
  <p>I was curious about the possible usages of this new feature, and I'm thinking in start to use it to replace optional arguments in functions, so:</p>
  
  <pre><code>void compute_something(int a, int b, const Object&amp; c = Object(whatever)) {
     // ...
  }
  </code></pre>
  
  <p>Becomes:</p>
  
  <pre><code>void compute_something(int a, int b, std::optional&lt;Object&gt; c) {
     auto tmp = c.value_or(Object(whatever));
     // ...
  }
  </code></pre>
  
  <p>According to the official doc:</p>
  
  <blockquote>
    <p>If an optional contains a value, the value is guaranteed to be
    allocated as part of the optional object footprint, i.e. no dynamic
    memory allocation ever takes place. Thus, an optional object models an
    object, not a pointer, even though the operator*() and operator->()
    are defined.</p>
  </blockquote>
  
  <p>So, every time we use a std::optional to pass arguments, it implies a creation of copies than can be a penalty performance if the object is big.</p>
  
  <p>I love the idea, because it make the code simpler and easy to understand but, is there any advantage? </p>