title: Why does this code hang during an insert of stl list
body: <p>Why this code is hang during insert of <code>stl</code> list?
  I have tried <code>copy</code> function also but it also not working. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;iterator&gt;
  #include &lt;list&gt;
  #include&lt;vector&gt;
  #include&lt;algorithm&gt;
  using namespace std; 
  
  class a{
      list&lt;string&gt; lista;
  
      public:
      a()
      {
  
          lista.push_back("ele");
          lista.push_back("phant");
          cout&lt;&lt;"End of Cons"&lt;&lt;endl;
      }
  
      list&lt;string&gt; getlist()
      {
          cout&lt;&lt;"Getting"&lt;&lt;endl;
          return lista;
      }
  };
  
  int main()
  {
  
      a A1;
  
      list&lt;string&gt; list1;
      list1.insert(list1.end(),A1.getlist().begin(),A1.getlist().end());
      //copy(A1.getlist().begin(),A1.getlist().end(),back_inserter(list1));
      cout&lt;&lt;"End of Prog"&lt;&lt;endl;
      return 0;
  
  }
  </code></pre>