title: How to resolve dangling const ref
body: <p>The following short program</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;iostream&gt;
  
  std::vector&lt;int&gt; someNums()
  {
      return {3, 5, 7, 11};
  }
  
  class Woop
  {
  public:
      Woop(const std::vector&lt;int&gt;&amp; nums) : numbers(nums) {}
      void report()
      {
          for (int i : numbers)
              std::cout &lt;&lt; i &lt;&lt; ' ';
          std::cout &lt;&lt; '\n';
      }
  private:
      const std::vector&lt;int&gt;&amp; numbers;
  };
  
  int main()
  {
      Woop woop(someNums());
      woop.report();
  }
  </code></pre>
  
  <p>has a dangling reference problem, that no compiler seems to warn about.
  The issue is that temporaries can be bound to const-refs, which you may
  then keep around. The question then is; Is there a method of avoiding getting into this problem? Preferably one that
  does not involve sacrificing const correctness, or always making
  copies of big objects.</p>