title: Can I unwrap std::map iterator to structured binding of optionals?
body: <p>Consider following code:</p>
  <pre><code>#include&lt;functional&gt;
  #include&lt;iostream&gt;
  #include&lt;map&gt;
  
  const std::map&lt;int, std::string&gt; numberToStr{{1, &quot;one&quot;}, {2,&quot;two&quot;}};
  int main() {
      auto it = numberToStr.find(2);
      if (it ==numberToStr.end()){
          return 1;
      }
      const auto&amp;[_, str] = *it;
      std::cout &lt;&lt; str;
  }
  </code></pre>
  <p>Is there any way for me to do the unwrapping of potentially dereferenced <code>it</code> to 2 optionals(_ and str) so I can then write:</p>
  <pre><code>const auto&amp;[_, str] = // some magic;
  // _ is std::optional&lt;int&gt;, str is std::optional&lt;str&gt;
  if (!str){
      return 1;
  }
  std::cout &lt;&lt; *str;
  }
  </code></pre>
  <p>I presume not since structured bindings are language level thing, and std::optional is a library feature and afaik there is no way to customize the interaction.</p>
  <p>Note: I presume I could implement my own map that returns iterators that know if they point to .end(), and &quot;hack&quot; customization points to do optional logic based on that, I am asking for general use case when I do not control the container.</p>