<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Difference between &#8220;vector v&#8221; and &#8220;vector v()&#8221;</title>
	<atom:link href="http://cplusplus.co.il/2009/08/11/difference-between-vector-v-and-vector-v/feed/" rel="self" type="application/rss+xml" />
	<link>http://cplusplus.co.il/2009/08/11/difference-between-vector-v-and-vector-v/</link>
	<description>Discussing modern C++ and related topics.</description>
	<lastBuildDate>Tue, 31 Jan 2012 01:36:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Or</title>
		<link>http://cplusplus.co.il/2009/08/11/difference-between-vector-v-and-vector-v/#comment-377</link>
		<dc:creator><![CDATA[Or]]></dc:creator>
		<pubDate>Tue, 20 Apr 2010 20:59:25 +0000</pubDate>
		<guid isPermaLink="false">http://cpptalk.wordpress.com/?p=3#comment-377</guid>
		<description><![CDATA[Yes, it&#039;s called The Most Vexing Parse, and it is a really vexing one. When you say vector v2() you are actually importing an external function(named v2 and that returns a vector of ints and has no parameters) from another translation unit.
This can be even more vexing if you write:
Suppose you want to read a file which his name stored in a variable filename, and copy it directly into a new vector:
[sourcecode language=&quot;cpp&quot;]
vector&lt;int&gt; v(istream_iterator&lt;int&gt;(filename), istream_iterator&lt;int&gt;());
[/sourcecode]
Although it is somehow not trivial example, that will be parsed by the vexing c++ compiler as a function declaration (because the parenthesis can be omitted to get a function declaration), not a vector initialization. to remedy the situation we have to do something like the following:
[sourcecode language=&quot;cpp&quot;]
istream_iterator&lt;int&gt; begin(filename);
istream_iterator&lt;int&gt; end;
vector&lt;int&gt; v(begin, end).
[/sourcecode]

Thanks!]]></description>
		<content:encoded><![CDATA[<p>Yes, it&#8217;s called The Most Vexing Parse, and it is a really vexing one. When you say vector v2() you are actually importing an external function(named v2 and that returns a vector of ints and has no parameters) from another translation unit.<br />
This can be even more vexing if you write:<br />
Suppose you want to read a file which his name stored in a variable filename, and copy it directly into a new vector:</p>
<pre class="brush: cpp;">
vector&lt;int&gt; v(istream_iterator&lt;int&gt;(filename), istream_iterator&lt;int&gt;());
</pre>
<p>Although it is somehow not trivial example, that will be parsed by the vexing c++ compiler as a function declaration (because the parenthesis can be omitted to get a function declaration), not a vector initialization. to remedy the situation we have to do something like the following:</p>
<pre class="brush: cpp;">
istream_iterator&lt;int&gt; begin(filename);
istream_iterator&lt;int&gt; end;
vector&lt;int&gt; v(begin, end).
</pre>
<p>Thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

