title: Nullify pointer before returning the address
body: <p>In the following code, for safety, I want to nullify the pointer before returning the address it stores. How can I do this?</p>
  
  <pre><code>int&amp; foo (vector&lt;int&gt;&amp; vec)
  {
      double dis = 1e6;
      int* ptr = NULL;
  
      for (int&amp; i: vec)
      {
          tmp = calculate (i);
  
          if (tmp &lt; dis)
          {
              dis = tmp;
              ptr = &amp;i;
          }
      }
  
      if (ptr != NULL)
      {
          // How to nullify the ptr?
          return *ptr;
      }
  }
  </code></pre>