<?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/"
		>
<channel>
	<title>Comments on: Difference between &#8220;vector v&#8221; and &#8220;vector v()&#8221;</title>
	<atom:link href="http://efesx.com/2009/08/11/difference-between-vector-v-and-vector-v/feed/" rel="self" type="application/rss+xml" />
	<link>http://efesx.com/2009/08/11/difference-between-vector-v-and-vector-v/</link>
	<description>Technical &#38; low level</description>
	<lastBuildDate>Mon, 30 Apr 2012 17:39:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Or</title>
		<link>http://efesx.com/2009/08/11/difference-between-vector-v-and-vector-v/#comment-7</link>
		<dc:creator>Or</dc:creator>
		<pubDate>Tue, 20 Apr 2010 20:59:25 +0000</pubDate>
		<guid isPermaLink="false">http://cpptalk.wordpress.com/?p=3#comment-7</guid>
		<description>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; title: ; notranslate">
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; title: ; notranslate">
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>

