title: function vs variable declaration in C++
body: <p>This code works:</p>
  
  <pre><code>std::ifstream f(mapFilename.c_str());
  std::string s = std::string(std::istreambuf_iterator&lt;char&gt;(f), std::istreambuf_iterator&lt;char&gt;());
  ParseGameState(s);
  </code></pre>
  
  <p>Whereby <code>mapFilename</code> is an <code>std::string</code> and <code>void ParseGameState(const std::string&amp;);</code>.</p>
  
  <p>And this does not:</p>
  
  <pre><code>std::ifstream f(mapFilename.c_str());
  std::string s(std::istreambuf_iterator&lt;char&gt;(f), std::istreambuf_iterator&lt;char&gt;());
  ParseGameState(s);
  </code></pre>
  
  <p>This is the error:</p>
  
  <pre><code>game.cpp: In member function ‘int Game::LoadMapFromFile(const std::string&amp;)’:
  game.cpp:423: error: no matching function for call to ‘ParseGameState(std::string (&amp;)(std::istreambuf_iterator&lt;char, std::char_traits&lt;char&gt; &gt;, std::istreambuf_iterator&lt;char, std::char_traits&lt;char&gt; &gt; (*)()))’
  game.cpp:363: note: candidates are: ParseGameState(const std::string&amp;)
  </code></pre>
  
  <p>So it seems that it recognizes <code>s</code> as a function declaration and not a variable declaration in this case.</p>
  
  <p>Why is that? Is this a bug in GCC 4.2.1 (Apple build)? Or does GCC handles this correctly? Is this undefined in the C++ standard?</p>