title: Calling Functions With std::optional Parameters
body: <p>I have a function whose signature is:</p>
  
  <pre><code>void func(std::optional&lt;std::string&gt; os = std::nullopt);
  </code></pre>
  
  <p>(I’m aliasing <code>std::experimental::optional</code> until <code>std::optional</code> is officially available.)</p>
  
  <p>However, I’m having difficulty calling it cleanly. The compiler will refuse to perform two implicit conversions (<code>const char*</code> ➝ <code>std::string</code> ➝ <code>std::optional&lt;std::string&gt;</code>) to call it with a raw C-string literal. I <em>can</em> do this:</p>
  
  <pre><code>func(std::string("Hello"));
  </code></pre>
  
  <p>And the compiler will figure that a <code>std::optional</code> is needed, and do the conversion. However, this is way too verbose. Thanks to C++11, I can also do this:</p>
  
  <pre><code>func({"Hello"});
  </code></pre>
  
  <p>While this is <em>way better</em>, it's still not ideal. I'd like to be able to call this function like any other that takes a <code>std::string</code>. <strong>Is this possible?</strong> Making the function take another parameter type is okay, as long as it behaves similarly to/is directly convertible to <code>std::optional</code>. Thanks.</p>