You changed the vector from a mutable one to an immutable one. That isn&#x27;t the same code. What if you need a mutable vector?<p>Also, consider this:<p><pre><code>      std::observer_ptr&lt;std::string const&gt; const foo() {
          std::vector&lt;std::string const&gt; const strings { &quot;Hello&quot; };
          return std::observer_ptr(&amp;strings[0]);
      }

      std::cout &lt;&lt; foo(); &#x2F;&#x2F; use after free, even with const!
</code></pre>
This is how these discussions always go: someone presents an example of use-after-free in C++, someone else says &quot;that&#x27;s contrived&quot;&#x2F;&quot;not real C++&quot;, and the discussion continues indefinitely. At some point we are going to just start debating &quot;does anyone actually write use-after-frees in modern C++?&quot;, which is also a question we have empirical answers to by way of vulnerability databases and bug trackers, and the results don&#x27;t look good for C++ there either.<p>If your contention is that observer_ptr is completely safe, then we could have easily added it to Rust. We didn&#x27;t for a reason: it&#x27;s unsafe in Rust and unsafe in C++.