<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>chys&#039;s random notes &#187; ICC</title>
	<atom:link href="http://en.chys.info/tag/icc/feed/" rel="self" type="application/rss+xml" />
	<link>http://en.chys.info</link>
	<description>Study more problems; Talk less of isms.</description>
	<lastBuildDate>Tue, 27 Dec 2011 11:56:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>C++0x in ICC 11</title>
		<link>http://en.chys.info/2009/05/cpp0x-in-icc11/</link>
		<comments>http://en.chys.info/2009/05/cpp0x-in-icc11/#comments</comments>
		<pubDate>Fri, 15 May 2009 18:07:48 +0000</pubDate>
		<dc:creator>chys</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++0x]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[ICC]]></category>

		<guid isPermaLink="false">http://en.chys.info/?p=515</guid>
		<description><![CDATA[Intel is advancing faster than GNU in support the upcoming C++0x. The two features I expect most, auto declaration and lambda function, have both been supported satisfactorily. Lambda functions that use variables defined outside (output_and_sum in the following demo) are supported as well as simpler ones (add in the following demo). #include &#60;cstdio&#62; #include &#60;algorithm&#62; [...]<hr/>
Related posts:<ol>
<li><a href='http://en.chys.info/2008/10/c0x-draft-finished/' rel='bookmark' title='C++0x draft finished'>C++0x draft finished</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Intel is advancing faster than GNU in support the upcoming <a href="http://en.wikipedia.org/wiki/C++0x">C++0x</a>. The two features I expect most, <code>auto</code> declaration and <a href="http://en.wikipedia.org/wiki/Lambda_calculus">lambda function</a>, have both been supported satisfactorily. Lambda functions that use variables defined outside (<code>output_and_sum</code> in the following demo) are supported as well as simpler ones (<code>add</code> in the following demo).</p>
<blockquote><pre>#include &lt;cstdio&gt;
#include &lt;algorithm&gt;
using namespace std;
&nbsp;
int main()
{
    static const int myvec[] = { 1, 2, 3, 4, 5 };
&nbsp;
    int sum = 0;
    <strong>auto</strong> add = <strong>[] (int a, int b) -&gt; int { return a+b; }</strong>;
    <strong>auto</strong> output_and_sum = <strong>[&#038;sum,add](int x) { sum  = add(sum,x); printf ("%d\n", x); }</strong>;
    for_each (myvec, myvec+5, output_and_sum);
    printf ("sum = %d\n", sum);
}</pre>
</blockquote>
<p>(I use <code>printf</code> instead of <code>cout</code> merely to make the assembly list more readable.)</p>
<p>ICC compiles this program (an option <code>-std=c++0x</code> is necessary, of course) and gives the correct resuls:</p>
<blockquote><pre>1
2
3
4
5
sum = 15</pre>
</blockquote>
<p>Also the two lambda functions are well inlined and optimized &#8211; variable <code>sum</code>, which is used by the lambda function by reference, is completely stored in a register, though it is easy to find several useless instructions in the assembly dump.</p>
<p>Some other less important (in my view) features (e.g. <code>initializer_list</code>) are not implemented yet. (BTW, I really had a hard time finding the &#8220;request noncommercial free license&#8221; link on Intel&#8217;s website, while I could see the link to &#8220;buy a commercial license&#8221; everywhere..)</p>
<p>Hopefully C++0x will be more successful than <a href="http://en.wikipedia.org/wiki/C99">C99</a>, which is filled with ugly and nobody-wants-to-implement features.</p>
<hr/><p>Related posts:<ol>
<li><a href='http://en.chys.info/2008/10/c0x-draft-finished/' rel='bookmark' title='C++0x draft finished'>C++0x draft finished</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://en.chys.info/2009/05/cpp0x-in-icc11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

