<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>C++0x, progress or pointless</title>
		<link>http://www.allegro.cc/forums/view/600179</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 15 May 2009 08:07:23 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This chap isn&#39;t impressed <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><p><a href="http://www.theregister.co.uk/2009/05/07/verity_stob_cplusplus/">http://www.theregister.co.uk/2009/05/07/verity_stob_cplusplus/</a></p><p>There are some funny quotes in his other posts:<br />&quot;The day they change the language name to ++C, that&#39;s the day I&#39;ll start taking pre-incrementing seriously.&quot;
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Thu, 07 May 2009 16:55:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>C++0x is pronounced &#39;sucks&#39; ;-).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Thu, 07 May 2009 18:33:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t know, C++0x looks like a pretty distant reach at this point. I mean {}... seriously? Why not just automatically initialize it like most other sane languages at this point. There&#39;s no good reason not to. This is stupid.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 07 May 2009 18:52:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Whining about {}?</p><div class="source-code snippet"><div class="inner"><pre><span class="p">#include &lt;stdio.h&gt;</span>

<span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span>
<span class="k2">{</span>
    <span class="k1">int</span> n <span class="k3">=</span> <span class="k2">{</span><span class="n">0</span><span class="k2">}</span><span class="k2">;</span>
    <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"%d"</span>, n<span class="k2">)</span><span class="k2">;</span>
    <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

This appears to be quite fine in C (you can&#39;t omit the 0 though, as you can with arrays).</p><p>If it does solve the &quot;most vexing parse&quot; in C++, is it such a bad thing? It&#39;s not like it would take days to learn the new initialization syntax...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Thu, 07 May 2009 19:17:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It is stupid and pointless. Why can&#39;t it be automatic?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 07 May 2009 19:22:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Some of that sounds useful. Some of it made no sense. <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" /> The <span class="source-code"><span class="k2">{</span><span class="k2">}</span></span> thing included.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Thu, 07 May 2009 19:26:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I vote pointless. In fact, I expect C and C++ to retreat to the inner sanctums of systems programming and other deep internal stuff — platforms are diverging and C/C++ sits at a suboptimal position in the application development hierarchy for 90% of the code for 99% of applications. C-like languages will thrive, but with either massively improved runtimes (C#, Objective-C) that ease the various binding/fragile base class/etc problems or in areas where code is short and performance is still the major objective (OpenCL, GLSlang/HLSL, device drivers). Even games have been following this path for years, with the C/C++ stuff doing graphics and physics and LUA-or-similar entrusted with all the interesting per-level stuff.</p><p>I&#39;m sure it&#39;ll be a lengthy transition and C/C++ won&#39;t suddenly be irrelevant tomorrow, but I don&#39;t see any real worth in attempts to further extend C++ at this stage. Take what works and re-engineer the rest ala C# if you&#39;re going to do anything — damn backwards compatibility.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Thu, 07 May 2009 19:33:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I can only imagine it makes sense with templates, as it allows you to initialize a variable of an unknown base type to its own default value.<br />(that was about {})
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Audric)</author>
		<pubDate>Thu, 07 May 2009 19:35:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>C# automatically initializes variables, making junk like {} useless. C++0x should do the same if its a serious language. But then you couldn&#39;t write major applications in it, so I don&#39;t know.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 07 May 2009 19:37:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810282#target">BAF</a> said:</div><div class="quote"><p>
It is stupid and pointless. Why can&#39;t it be automatic? 
</p></div></div><p>

Because you can expect the revenge of former C programmers? For years they have been promised that there is no extra overhead if they don&#39;t want to have their POD initialized at this point. Can you imagine that now when they have been almost won over, C++ can suddenly turn its back to them and bring in that overhead? <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Thu, 07 May 2009 19:37:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Former C programmers can take a hike then. If they like their ancient archaic crap, they can keep using it. Why limit usefulness of new languages because of the rare case where some masochistic C/asm programmer wants to control when their variable is initialized?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 07 May 2009 19:43:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810288#target">BAF</a> said:</div><div class="quote"><p>
C# automatically initializes variables, making junk like {} useless.
</p></div></div><p>

I have been playing around with C# for a couple of days now, and it seems to me that it is not entirely true. It is an error to try to use uninitialized local variables, though, and since they need to be explicitly initialized, crap like {} (or any other syntax, which is really just a minor detail) is still necessary.</p><p>It seems rather stupid to argue which of the two is that much better:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">int</span> i<span class="k2">{</span><span class="k2">}</span><span class="k2">;</span> <span class="c">//perhaps more obscure but useful with templates</span>
<span class="k1">int</span> i <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Thu, 07 May 2009 19:49:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Some people can&#39;t work in C# or Python (for example: people who write drivers for hardware.)<br />I know next to nothing of C++0x, but if it is a new (improved?) tool available for them, I consider it a good thing.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Audric)</author>
		<pubDate>Thu, 07 May 2009 19:51:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>How many drivers are written in C++ anyway? I doubt C++0x will be used for drivers.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 07 May 2009 19:52:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I am sure that GCC will add a bunch of extentions that will allow you to write a mixture of C++98 and C++0x.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Timorg)</author>
		<pubDate>Thu, 07 May 2009 19:54:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If I&#39;m not mistaken, the language will be (mostly) backward compatible with the earlier standards. You will be able to write old-style C++ all along, there will just be better ways.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Thu, 07 May 2009 19:59:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Depending on your definition of better. I define better as changing languages all together. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 07 May 2009 20:01:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If everyone is dead set against c/c++, why are we all (THarte Excepted) writing our allegro games in c/c++ and what are we doing at allegro.cc anyway <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Thu, 07 May 2009 20:19:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t know about you, but I haven&#39;t done much game programming at all. I&#39;ve been using C# almost exclusively for a while now.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 07 May 2009 20:21:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I still prefer C and C++ to C#, actually. C# is the better tool a lot of times simply because it&#39;s higher level and has the .NET framework to build from (I don&#39;t dare subject myself to Microsoft&#39;s managed C++), but there are often times when the power to do something is taken away from me because of the way the language was designed. I&#39;ve seen and even written, against my own intentions, a lot of really ugly C# code. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /> C++ would benefit from a richer standard library and some more syntactic sugar. I think overall C++0x will be a good thing.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Thu, 07 May 2009 20:26:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It&#39;s supposed to be an attempt to unify the syntax of object construction. You&#39;d use it anytime except when existing constructors would interfere with added constructors. E.g</p><div class="source-code snippet"><div class="inner"><pre>std::vector<span class="k3">&lt;</span>int&gt; vec<span class="k2">{</span><span class="n">4</span><span class="k2">}</span><span class="k2">;</span> <span class="c">//contains one element with value 4</span>
std::vector<span class="k3">&lt;</span>int&gt; vec<span class="k2">(</span><span class="n">4</span><span class="k2">)</span><span class="k2">;</span> <span class="c">//contains four elements with value 0</span>
</pre></div></div><p>

Where it is useful?</p><div class="source-code snippet"><div class="inner"><pre>std::vector<span class="k3">&lt;</span>int&gt; vec<span class="k2">(</span>std::istream_iterator<span class="k3">&lt;</span>int&gt;<span class="k2">(</span>std::cin<span class="k2">)</span>, std::istream_iterator<span class="k3">&lt;</span>int&gt;<span class="k2">(</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span> <span class="c">//that's called vexing</span>
std::vector<span class="k3">&lt;</span>int&gt; vec<span class="k2">{</span>std::istream_iterator<span class="k3">&lt;</span>int&gt;<span class="k2">(</span>std::cin<span class="k2">)</span>, std::istream_iterator<span class="k3">&lt;</span>int&gt;<span class="k2">(</span><span class="k2">)</span><span class="k2">}</span><span class="k2">;</span> <span class="c">//much better</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Thu, 07 May 2009 20:34:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810303#target">Neil Walker</a> said:</div><div class="quote"><p>If everyone is dead set against c/c++, why are we all (THarte Excepted) writing our allegro games in c/c++ and what are we doing at allegro.cc anyway </p></div></div><p>
I thought you were a C# boy nowadays? And I was also under the impression that a bunch of other people were, quite beside the few I know for certain are in the iPhone Objective-C realm.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Thu, 07 May 2009 20:42:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There is absolutely no way I will be able to avoid c/c++ in my line of work. The problem with c++0x is that it is too little too late IMO. These things should have been included 10 years ago so I would have a hope of using them by now. By the time code-bases like ITK start accepting the changes I will be an old man.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Goalie Ca)</author>
		<pubDate>Thu, 07 May 2009 21:22:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810313#target">Thomas Harte</a> said:</div><div class="quote"><p>I thought you were a C# boy nowadays? And I was also under the impression that a bunch of other people were, quite beside the few I know for certain are in the iPhone Objective-C realm.</p></div></div><p>I am at work (well, depends what I&#39;m doing - which at the minute I have no idea as I&#39;m working drip-feed week by week, plus almost all coding is now offshored to clueless Indian students so that&#39;s ramping down as wel), but at home I do c++ (or try to) which is predominantly allegro. </p><p>If it weren&#39;t for allegro I wouldn&#39;t be using it at all, however I do see c/c++ as the syntax father of all the languages I currently use (c#, java, php) so it&#39;s best to keep up I think.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Thu, 07 May 2009 21:34:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m still trying to figure out why the hell you would ever want to write &quot;auto someFunc() -&gt; int {}&quot; instead of just &quot;int someFunc() {}&quot; - my mind fails to produce any scenario where this would even be close to useful. It seems like they introduced syntax stupidities such as this (which is even worse than ={};) just for something to do because they ran out of intelligent ideas.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 07 May 2009 21:36:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The Wikipedia article quotes this usage:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">template</span><span class="k3">&lt;</span> <span class="k1">typename</span> LHS, <span class="k1">typename</span> RHS&gt; 
  <span class="k1">auto</span> AddingFunc<span class="k2">(</span><span class="k1">const</span> LHS <span class="k3">&amp;</span>lhs, <span class="k1">const</span> RHS <span class="k3">&amp;</span>rhs<span class="k2">)</span> <span class="k3">-</span><span class="k3">&gt;</span> decltype<span class="k2">(</span>lhs<span class="k3">+</span>rhs<span class="k2">)</span> <span class="k2">{</span><span class="k1">return</span> lhs <span class="k3">+</span> rhs<span class="k2">;</span><span class="k2">}</span>
</pre></div></div><p>

Apparently you&#39;ll only need it when the return type would depend on the types of the arguments.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Thu, 07 May 2009 21:43:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok then. I think we&#39;ve exhausted the {} debate for now.<br />How about we discuss something else that&#39;s new in C++0x?</p><p>I&#39;m not gonna do the discussing though, I just think it&#39;s getting boring to follow the thread when you just argue over a single feature.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trezker)</author>
		<pubDate>Thu, 07 May 2009 21:51:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Can&#39;t you do that already with templates without that syntax though?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 07 May 2009 21:55:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810325#target">anonymous</a> said:</div><div class="quote"><p>Apparently you&#39;ll only need it when the return type would depend on the types of the arguments.</p></div></div><p>
It makes sense, although that&#39;s probably the <i>only</i> time it should be used (and anybody that tries to use it unnecessarily should be shot).
</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810329#target">Trezker</a> said:</div><div class="quote"><p>Ok then. I think we&#39;ve exhausted the {} debate for now.<br />How about we discuss something else that&#39;s new in C++0x?</p><p>I&#39;m not gonna do the discussing though, I just think it&#39;s getting boring to follow the thread when you just argue over a single feature. </p></div></div><p>
They were actually just arguing about a different feature. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810330#target">BAF</a> said:</div><div class="quote"><p>Can&#39;t you do that already with templates without that syntax though?</p></div></div><p>
If you don&#39;t know what the types are then how can you know what adding them together will give you? I think that&#39;s why this exists. So the compiler knows <i>the return type is the result of adding these types together</i>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Thu, 07 May 2009 21:57:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It seems like quite a stretch to me.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 07 May 2009 22:00:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It seems evil, but a necessary evil.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Thu, 07 May 2009 22:01:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Please give a useful example of how it is useful then. The example anonymous gave is quite a stretch, how often does your return value depend on mroe than one template parameter?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 07 May 2009 22:02:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810334#target">BAF</a> said:</div><div class="quote"><p>Please give a useful example of how it is useful then. The example anonymous gave is quite a stretch, how often does your return value depend on mroe than one template parameter?</p></div></div><p>
In C#/.NET, when you use the <span class="source-code"><span class="k3">+</span></span> or <span class="source-code"><span class="k3">-</span></span> operator with two <span class="source-code">System.DateTime</span>s, the result is a <span class="source-code">System.TimeSpan</span>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Thu, 07 May 2009 22:05:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810289#target">anonymous</a> said:</div><div class="quote"><p>
there is no extra overhead if they don&#39;t want to have their POD initialized at this point.
</p></div></div><p>

What&#39;s POD?  The closest definitions I could find were Portable On Demand and Prince Of Darkness.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Thu, 07 May 2009 22:54:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810340#target">Arthur Kalliokoski</a> said:</div><div class="quote"><p>What&#39;s POD? The closest definitions I could find were Portable On Demand and Prince Of Darkness.</p></div></div><p>
<a href="http://en.wikipedia.org/wiki/Pod#Computers">http://en.wikipedia.org/wiki/Pod#Computers</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Thu, 07 May 2009 23:02:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Plain Old Data Structures?  That&#39;s PODS.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Thu, 07 May 2009 23:05:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you don&#39;t use C/C++, you shouldn&#39;t be posting in this thread, because, clearly, you don&#39;t need the special features those two languages provide.</p><p>That article is yet another FQA-like bit of nonsense... except it&#39;s about C++0x. Yes, it&#39;s not perfect, but what other choice is there when you want to do numerical programming?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Thu, 07 May 2009 23:19:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><a href="http://en.wikipedia.org/wiki/Category:Numerical_programming_languages">Any of these would also do the job I am sure</a>, But Fortran 2003 comes to mind.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Timorg)</author>
		<pubDate>Thu, 07 May 2009 23:42:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, FORTRAN is the only serious alternative to my knowledge, but I would scarcely say that it is all that much more user friendly than the C/C++ duo.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Thu, 07 May 2009 23:45:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>C/C++/C++0x aren&#39;t in that list at all.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Thu, 07 May 2009 23:46:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810335#target">bamccaig</a> said:</div><div class="quote"><p>
In C#/.NET, when you use the + or - operator with two System.DateTimes, the result is a System.TimeSpan.
</p></div></div><p>

That&#39;s not a good example. I mean a useful example where you would even want to do something like the original snippet.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 07 May 2009 23:52:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I remember a thread in Gamedev where someone wanted to make Vector&lt;int&gt; + Vector&lt;double&gt; return Vector&lt;double&gt; (or generally Vector&lt;the_type_that_the_result_is_promoted_to&gt;). It can be simulated (at least to some extent) with some metaprogramming, but C++0x would allow this quite simply.</p><p>It is probably not a very practical example, just something that a zealous library-writer thought would be cool.</p><p>Another thing is that perhaps it can provide a small shortcut to things that are tedious to type:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">template</span> <span class="k3">&lt;</span><span class="k1">class</span> T&gt;
<span class="k1">typename</span> std::vector<span class="k3">&lt;</span>T&gt;::const_iterator foo<span class="k2">(</span><span class="k1">const</span> std::vector<span class="k3">&lt;</span>T&gt;<span class="k3">&amp;</span> vec<span class="k2">)</span><span class="k2">;</span>

<span class="k1">template</span> <span class="k3">&lt;</span><span class="k1">class</span> T&gt;
<span class="k1">auto</span> foo<span class="k2">(</span><span class="k1">const</span> std::vector<span class="k3">&lt;</span>T&gt;<span class="k3">&amp;</span> vec<span class="k2">)</span> <span class="k3">-</span><span class="k3">&gt;</span> decltype<span class="k2">(</span>vec.end<span class="k2">(</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Ok, not that much shorter, and probably not entirely clear <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /> (This, I believe, would actually be simplified by template typedefs.) </p><p>It is quite likely that its main usefulness would be in template metaprogramming or with some new features like variadic templates.</p><p>In practice it&#39;s happening every time you add values of different type: they are promoted to something but you&#39;ll just assign (cast) them to some type to store the result.</p><p>-----</p><p>If I&#39;m not mistaken, all the features don&#39;t come from some committee. Real programmers like you and me can (could) make suggestions, and then the committee would discuss which are actually good ideas, which are feasible to implement, which would break existing code etc.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Fri, 08 May 2009 00:25:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>But in C++0x you can write</p><div class="source-code snippet"><div class="inner"><pre>
<span class="k1">auto</span> someFunc<span class="k2">(</span><span class="k2">)</span> <span class="k3">-</span><span class="k3">&gt;</span> <span class="k1">int</span>
<span class="k2">{</span> <span class="c">// function body...</span>
</pre></div></div><p>
</p></div></div><p>

It would be nice without the auto keyword. It looks more like a return value.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Martin Kalbfuß)</author>
		<pubDate>Fri, 08 May 2009 01:06:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810360#target">anonymous</a> said:</div><div class="quote"><p>
I remember a thread in Gamedev where someone wanted to make Vector&lt;int&gt; + Vector&lt;double&gt; return Vector&lt;double&gt;
</p></div></div><p>
Someone who wants to do this should re-think their coding habits.<br />The proper solution is a utility function that takes one Vector&lt;int&gt; and one Vector&lt;double&gt; and returns a Vector&lt;double&gt;. Even with vectors of the same contained type, operator+ isn&#39;t intuitive - addition could be understood to mean any of:<br />- append all elements of A to C, then append all elements of B to C, then return C<br />- append all elements of A to C, then append all elements of B that are not elements of A to C, then return C<br />- for each element in A, find the element at the same position in B, calculate their sum, and append it to C; then return C</p><p>Facilitating something like this isn&#39;t cool, it leads to the kind of unmaintainable convoluted code the C folks are so proud of, or the kind of template abuse some C++ programmers seem to love so much.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Fri, 08 May 2009 13:53:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810303#target">Neil Walker</a> said:</div><div class="quote"><p>If everyone is dead set against c/c++, why are we all (THarte Excepted) writing our allegro games in c/c++</p></div></div><p>
</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810321#target">Neil Walker</a> said:</div><div class="quote"><p>If it weren&#39;t for allegro I wouldn&#39;t be using it at all</p></div></div><p>
Allegro# 2.0 this summer. (Well, 1.9 until A5 officially comes out.)</p><p>Also, I&#39;m not digging C++0x.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Fri, 08 May 2009 17:47:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810440#target">Tobias Dammers</a> said:</div><div class="quote"><p>
Someone who wants to do this should re-think their coding habits.
</p></div></div><p>

The question was about the geometrical vector, not the container.</p><p>I understand that it was an entirely theoretical discussion, since in practice it probably won&#39;t be that necessary, but C++0x would allow one to implement it like this:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">template</span> <span class="k3">&lt;</span><span class="k1">class</span> T, <span class="k1">class</span> U&gt;
<span class="k1">auto</span> <span class="k1">operator</span><span class="k3">+</span><span class="k2">(</span><span class="k1">const</span> Vector<span class="k3">&lt;</span>T&gt;<span class="k3">&amp;</span> a, <span class="k1">const</span> Vector<span class="k3">&lt;</span>U&gt;<span class="k3">&amp;</span> a<span class="k2">)</span> <span class="k3">-</span><span class="k3">&gt;</span> Vector<span class="k3">&lt;</span>decltype<span class="k2">(</span>a.x <span class="k3">+</span> b.x<span class="k2">)</span><span class="k3">&gt;</span>
<span class="k2">{</span>
    <span class="k1">return</span> <span class="k2">{</span>a.x <span class="k3">+</span> b.x, a.y <span class="k3">+</span> b.y<span class="k2">}</span><span class="k2">;</span> <span class="c">//another advantage of new constructor syntax?</span>
<span class="k2">}</span>
</pre></div></div><p>

Right now what you could do is:</p><div class="source-code snippet"><div class="inner"><pre><span class="c">//lots of metaprogramming here</span>

<span class="k1">template</span> <span class="k3">&lt;</span><span class="k1">class</span> T, <span class="k1">class</span> U&gt;
Vector<span class="k3">&lt;</span>promote<span class="k3">&lt;</span>T, U&gt;::type <span class="k3">&gt;</span> <span class="k1">operator</span><span class="k3">+</span><span class="k2">(</span><span class="k1">const</span> Vector<span class="k3">&lt;</span>T&gt;<span class="k3">&amp;</span> a, <span class="k1">const</span> Vector<span class="k3">&lt;</span>T&gt;<span class="k3">&amp;</span> b<span class="k2">)</span>
<span class="k2">{</span>
    <span class="k1">return</span> Vector<span class="k3">&lt;</span>promote<span class="k3">&lt;</span>T, U&gt;::type <span class="k3">&gt;</span><span class="k2">(</span>a.x <span class="k3">+</span> b.x, a.y <span class="k3">+</span> b.y<span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

Or perhaps support just a few vector types (who needs many different types anyway) and define the int + int -&gt; int and double + double -&gt; double versions (if the implicit conversions work, if not also int + double -&gt; double and double + int -&gt; double).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Fri, 08 May 2009 18:26:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;d go for overloading just operator +=. This way, the return type is obvious, and it&#39;s up to the user to decide which return type they want:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">template</span> <span class="k3">&lt;</span><span class="k1">class</span> T&gt; 
<span class="k1">class</span> Vector<span class="k3">&lt;</span>T&gt; <span class="k2">{</span>
   <span class="c">//...</span>
   <span class="k1">template</span> <span class="k3">&lt;</span><span class="k1">class</span> U&gt; 
   Vector<span class="k3">&lt;</span>T&gt; <span class="k1">operator</span><span class="k3">+</span><span class="k3">=</span><span class="k2">(</span><span class="k1">const</span> Vector<span class="k3">&lt;</span>U&gt; rhs<span class="k2">)</span> <span class="k2">{</span>
     x <span class="k3">+</span><span class="k3">=</span> rhs.x<span class="k2">;</span>
     y <span class="k3">+</span><span class="k3">=</span> rhs.y<span class="k2">;</span>
     <span class="k1">return</span> <span class="k3">*</span><span class="k1">this</span><span class="k2">;</span>
   <span class="k2">}</span>
<span class="k2">}</span>
</pre></div></div><p>
Or ditch the overloading for incompatible types and use a static method:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">template</span> <span class="k3">&lt;</span><span class="k1">class</span> T&gt; 
<span class="k1">class</span> Vector<span class="k3">&lt;</span>T&gt; <span class="k2">{</span>
   <span class="c">//...</span>
   <span class="k1">template</span> <span class="k3">&lt;</span><span class="k1">class</span> U, <span class="k1">class</span> V&gt; 
   <span class="k1">static</span> Vector<span class="k3">&lt;</span>T&gt; add<span class="k2">(</span><span class="k1">const</span> Vector<span class="k3">&lt;</span>U&gt; a, <span class="k1">const</span> Vector<span class="k3">&lt;</span>V&gt; b<span class="k2">)</span> <span class="k2">{</span>
     <span class="k1">return</span> Vector<span class="k3">&lt;</span>T&gt;<span class="k2">(</span><span class="k2">(</span>T<span class="k2">)</span><span class="k2">(</span>a.x <span class="k3">+</span> b.x<span class="k2">)</span>, <span class="k2">(</span>T<span class="k2">)</span><span class="k2">(</span>a.y <span class="k3">+</span> b.y<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
   <span class="k2">}</span>
<span class="k2">}</span>
</pre></div></div><p>

Or choose maintainability over cleverness and do everything with just Vector&lt;double&gt;, except at the very last stage, where you use Vector&lt;int&gt;. Then all you need is a templated copy constructor that can initialize a Vector&lt;T&gt; from a Vector&lt;U&gt;, and you&#39;re done.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Fri, 08 May 2009 19:15:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810511#target">Tobias Dammers</a> said:</div><div class="quote"><p>
I&#39;d go for overloading just operator +=.
</p></div></div><p>

But this is against convention. If the types support +=, they should also support equivalent + <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Or ditch the overloading for incompatible types and use a static method
</p></div></div><p>

Except the calls would be rather awkward:</p><div class="source-code snippet"><div class="inner"><pre>c <span class="k3">=</span> Vector<span class="k3">&lt;</span>double&gt;::add<span class="k2">(</span>a, b<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

If one is writing a library to be used often, I&#39;m all for the one-time investment to make things more pleasant for the end user.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Or choose maintainability over cleverness
</p></div></div><p>

I&#39;ve never said that the whole thing is meant to be practical... but isn&#39;t it nice if you can do it simply?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Fri, 08 May 2009 20:23:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I prefer languages that discourage impractical code.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Fri, 08 May 2009 20:29:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Todays C++ also discourages it.</p><p>In practice it seems that it can simplify your prototypes (a bit like I showed above, but instead with a out-of-line member function definition involving nested types as the return value) and it may have something to do with SFINAE (well, not my line).</p><p>I guess it is also a compromise with compiler implementators (if I&#39;m not mistaken the standard committee is trying to avoid repeating the &quot;export&quot; mistake - a very useful feature which practically all compiler writers found too difficult to implement).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Fri, 08 May 2009 20:43:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810343#target">SiegeLord</a> said:</div><div class="quote"><p>If you don&#39;t use C/C++, you shouldn&#39;t be posting in this thread, because, clearly, you don&#39;t need the special features those two languages provide.</p></div></div><p>
I&#39;m not sure this argument entirely holds water. I obviously get a special pass because I&#39;m using a superset of C/C++, but couldn&#39;t it be that someone considers the special features highly desirable rather than absolutely essential, so has an interest in the language but nevertheless on balance may find themselves not using it?</p><p>Anyway, is the linked-to article right that the optional new method of providing return-value-like functionality is designed to make more efficient use of the call stack?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Fri, 08 May 2009 21:40:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810541#target">Thomas Harte</a> said:</div><div class="quote"><p>
I&#39;m not sure this argument entirely holds water. I obviously get a special pass because I&#39;m using a superset of C/C++, but couldn&#39;t it be that someone considers the special features highly desirable rather than absolutely essential, so has an interest in the language but nevertheless on balance may find themselves not using it?
</p></div></div><p>
Yeah, I retract that statement.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Fri, 08 May 2009 22:34:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810541#target">Thomas Harte</a> said:</div><div class="quote"><p>
Anyway, is the linked-to article right that the optional new method of providing return-value-like functionality is designed to make more efficient use of the call stack? 
</p></div></div><p>

What exactly do you have in mind? This?</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
int&amp;&amp; r2 = foo(); // foo() returns an int
</p></div></div><p>

This is supposed to allow to avoid unnecessary copying of objects. E.g you have a local object in a function and eventually you return it. Now, rather than having it destructed at the end of the function and a copy made for returning, you can have it &quot;moved&quot; right into the receiving object at the point of call.</p><p>I&#39;m not too familiar with that idea to know if there are going to be any new horrible pitfalls. It&#39;s probably also to compensate that in newer languages most everything is a reference and copies should be rather few, while not making everything a reference (perhaps that would simply make C++ something completely different than what it is, and I don&#39;t see much point in wanting it to become another C# or whatever).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Sat, 09 May 2009 03:42:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>With C covering the low-level, and languages like C#, Javascript covering the high-level, there&#39;s no need for the inbetween oddities like C++0x. </p><p>That&#39;s my biased C-programmer opinion.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Paul Pridham)</author>
		<pubDate>Sat, 09 May 2009 20:17:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810587#target">anonymous</a> said:</div><div class="quote"><p>
This is supposed to allow to avoid unnecessary copying of objects. E.g you have a local object in a function and eventually you return it. Now, rather than having it destructed at the end of the function and a copy made for returning, you can have it &quot;moved&quot; right into the receiving object at the point of call.</p><p>I&#39;m not too familiar with that idea to know if there are going to be any new horrible pitfalls. It&#39;s probably also to compensate that in newer languages most everything is a reference and copies should be rather few, while not making everything a reference (perhaps that would simply make C++ something completely different than what it is, and I don&#39;t see much point in wanting it to become another C# or whatever). 
</p></div></div><p>

Judging from the auto_ptr fiasco that had move semantics, I say that this moving thing will be a disaster. Imagine a move operation in the middle of a complex expression!</p><p>The academics say that destructive updating in programs is bad and should be avoided. And then comes C++0x and introduces even more destructive updating...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Sat, 09 May 2009 20:46:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810658#target">axilmar</a> said:</div><div class="quote"><p>
Judging from the auto_ptr fiasco that had move semantics, I say that this moving thing will be a disaster. Imagine a move operation in the middle of a complex expression!
</p></div></div><p>

From the Wikipedia article:</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
For safety reasons a named variable will never be considered to be an rvalue even if it&#39;s declared as such; in order to get an rvalue the library function std::move() should be used.
</p></div></div><p>

Not that I understand these things perfectly, it seems that the point of rvalue references is <i>to allow implementing</i> move semantics, rather than making things move around implicitly.</p><p>P.S I&#39;m very new to C#, but it appears such unexpected destruction of stuff is also possible (it won&#39;t lead to undefined behaviour, but shooting yourself with a rubber bullet isn&#39;t nice either):</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><span class="k1">using</span> System<span class="k2">;</span>
<span class="number">  2</span><span class="k1">namespace</span> Test
<span class="number">  3</span><span class="k2">{</span>
<span class="number">  4</span>    <span class="k1">class</span> App
<span class="number">  5</span>    <span class="k2">{</span>
<span class="number">  6</span>        <span class="k1">static</span> <span class="k1">void</span> Main<span class="k2">(</span><span class="k2">)</span>
<span class="number">  7</span>        <span class="k2">{</span>
<span class="number">  8</span>            X a <span class="k3">=</span> <span class="k1">new</span> X<span class="k2">(</span><span class="n">42</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  9</span>            <span class="k1">using</span> <span class="k2">(</span>X b <span class="k3">=</span> a<span class="k2">)</span>
<span class="number"> 10</span>            <span class="k2">{</span>
<span class="number"> 11</span>                Console.WriteLine<span class="k2">(</span><span class="s">"{0}"</span>, b.Value<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 12</span>            <span class="k2">}</span>
<span class="number"> 13</span>            Console.WriteLine<span class="k2">(</span><span class="s">"{0}"</span>, a.Value<span class="k2">)</span><span class="k2">;</span> <span class="c">//the "valuable resource" has been already disposed</span>
<span class="number"> 14</span>        <span class="k2">}</span>
<span class="number"> 15</span>    <span class="k2">}</span>
<span class="number"> 16</span>
<span class="number"> 17</span>    <span class="k1">class</span> X <span class="k2">:</span> IDisposable
<span class="number"> 18</span>    <span class="k2">{</span>
<span class="number"> 19</span>        <span class="k1">private</span> <span class="k1">int</span> n<span class="k2">;</span>
<span class="number"> 20</span>        <span class="k1">public</span> <span class="k1">int</span> Value 
<span class="number"> 21</span>        <span class="k2">{</span>
<span class="number"> 22</span>            get
<span class="number"> 23</span>            <span class="k2">{</span>
<span class="number"> 24</span>                <span class="k1">return</span> n<span class="k2">;</span>
<span class="number"> 25</span>            <span class="k2">}</span>
<span class="number"> 26</span>        <span class="k2">}</span>
<span class="number"> 27</span>        <span class="k1">public</span> X<span class="k2">(</span><span class="k1">int</span> m<span class="k2">)</span> 
<span class="number"> 28</span>        <span class="k2">{</span> 
<span class="number"> 29</span>            n <span class="k3">=</span> m<span class="k2">;</span> 
<span class="number"> 30</span>        <span class="k2">}</span>
<span class="number"> 31</span>        <span class="k1">public</span> <span class="k1">void</span> Dispose<span class="k2">(</span><span class="k2">)</span>
<span class="number"> 32</span>        <span class="k2">{</span>
<span class="number"> 33</span>            n <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 34</span>        <span class="k2">}</span>
<span class="number"> 35</span>    <span class="k2">}</span>
<span class="number"> 36</span><span class="k2">}</span>
</div></div><p>

</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810654#target">Paul Pridham</a> said:</div><div class="quote"><p>
With C covering the low-level, and languages like C#, Javascript covering the high-level, there&#39;s no need for the inbetween oddities like C++0x.
</p></div></div><p>

So does this mean that low-level programming should be almost as hard as possible and high-level should insulate you from all lower-level details and there is never a case for a middle way?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Sat, 09 May 2009 22:05:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Having only pure high level and low level languages would mean you need to use two different languages in your project if you wish to use high and low in different places.</p><p>I very much like C++ because it lets you go high and low whenever you need. Even though the language has some troublesome issues. I&#39;d like to use a language that solves the issues but keeps that ability.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trezker)</author>
		<pubDate>Sat, 09 May 2009 22:45:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810675#target">Trezker</a> said:</div><div class="quote"><p>I very much like C++ because it lets you go high and low whenever you need.</p></div></div><p>

All of the convenience of a low-level language along with the performance of a high-level language. <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (amber)</author>
		<pubDate>Sat, 09 May 2009 22:54:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I am of the opinion that C++ (or C++0x for the matter) is a great choice for those who want abstraction without sacrificing performance. <br />C doesn&#39;t even support the abstraction of simple classes. <br />A reason against using higher level languages for performance sensitive applications can be the following: In Java or C# if one creates a simple class to abstract a simple concept one necessarily incurs the overhead of having to create it on the heap. Such a little class may be used extensively and impact performance in unacceptable ways.</p><p><img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (enric)</author>
		<pubDate>Sun, 10 May 2009 00:13:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I am cautiously optimistic. I read some of the features, a few appear useful. However, until a commercial developer decides to implement it (like Microsoft) I doubt I will be using it in the next few years. Mostly for home made testing, but nothing serious.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ReyBrujo)</author>
		<pubDate>Sun, 10 May 2009 00:52:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810692#target">enric</a> said:</div><div class="quote"><p>
In Java or C# if one creates a simple class to abstract a simple concept one necessarily incurs the overhead of having to create it on the heap.
</p></div></div><p>
This is not true.<br />First of all, Java runs in a virtual machine, and the implementation can use all sorts of optimizations in the JIT compilation, which may or may not allocate an object at all (just like in C++ compilation, local variables may even be optimized away completely).<br />Second; C# has &quot;value types&quot; which are always passed by value, which is the same as passing a C++ object by value. C# also offers &quot;unsafe&quot; mode with C++ style pointer semantics.
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Such a little class may be used extensively and impact performance in unacceptable ways.
</p></div></div><p>
Stack vs. heap is rarely a performance killer these days, and if it is, the solution is to write a utility library that does the dirty work in a low level language, say, C++, and call its functions from a higher level language. <br />If you ask me, C++ is complicated enough as it is, with too many features and too many ways of doing the same thing for a maintenance programmer to efficiently master, and throwing more obscure features at it isn&#39;t going to make things any better.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Sun, 10 May 2009 01:06:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The real performance killer is not being able to properly optimize the data cache. Doesn&#39;t matter what language.. if the generated code sucks then it sucks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Goalie Ca)</author>
		<pubDate>Sun, 10 May 2009 01:51:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The real performance killer is arguing over this sort of stuff all of the time instead of making games with Allegro. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Paul Pridham)</author>
		<pubDate>Sun, 10 May 2009 07:17:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810654#target">Paul Pridham</a> said:</div><div class="quote"><p>With C covering the low-level, and languages like C#, Javascript covering the high-level, there&#39;s no need for the inbetween oddities like C++0x. </p><p>That&#39;s my biased C-programmer opinion.</p></div></div><p>

Funny to read that on a game programming forum of all places.  Modern games (I&#39;m talking AAA titles here, not little hobbyist projects) can benefit massively from C++&#39;s features that C lacks, but they usually can&#39;t afford the overhead of a language like Java or C#.  Even if everyone else ditched C++, I&#39;d expect game devs would probably be some of the last holdouts.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Speedo)</author>
		<pubDate>Sun, 10 May 2009 07:50:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810666#target">anonymous</a> said:</div><div class="quote"><p>
Not that I understand these things perfectly, it seems that the point of rvalue references is to allow implementing move semantics, rather than making things move around implicitly.
</p></div></div><p>

The moving operation may be buried deep inside a function and not be visible at all.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Sun, 10 May 2009 13:21:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810843#target">axilmar</a> said:</div><div class="quote"><p>
The moving operation may be buried deep inside a function and not be visible at all. 
</p></div></div><p>

You mean something like:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">template</span> <span class="k3">&lt;</span><span class="k1">class</span> T&gt;
<span class="k1">void</span> swap<span class="k2">(</span>T<span class="k3">&amp;</span> a, T<span class="k3">&amp;</span> b<span class="k2">)</span>
<span class="k2">{</span>
    T tmp <span class="k3">=</span> move<span class="k2">(</span>a<span class="k2">)</span><span class="k2">;</span>
    a <span class="k3">=</span> move<span class="k2">(</span>b<span class="k2">)</span><span class="k2">;</span>
    <span class="c">//oops, forgot to put anything back in b</span>
<span class="k2">}</span>
</pre></div></div><p>

I guess it will add ways to shoot yourself in the foot but what I gather is that objects will not start vanishing on their own if you don&#39;t explicitly tell them to, and hopefully you&#39;ll test your functions anyway. (If this was regular swap, and you forgot the third assignment, it would be broken too.)</p><p>It seems that mostly one would provide overloads for rvalue references is for copy constructors and assignment operators. (But not all classes need them.) I wonder if those overloads would be automatically generated, if my class is entirely composed of classes that already implement those (like normal copy constructor/assignment operator today). If it was so, that would be super: I&#39;d write code the same way as before, except STL has become more efficient...</p><p>-------<br />&lt;edit&gt;<br />Also, when it comes to functions having side-effects, you wouldn&#39;t call them in complex expressions even today - at least when the side-effects would concern the same value.</p><p>E.g, you wouldn&#39;t call a function that takes two strings, like this:
</p><div class="source-code snippet"><div class="inner"><pre>foo<span class="k2">(</span>s <span class="k3">=</span> to_upper<span class="k2">(</span>s<span class="k2">)</span>, s<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

since it would be unknown whether the second s would end up being as originally or in upper-case.<br />&lt;/edit&gt;
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Sun, 10 May 2009 17:33:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810885#target">anonymous</a> said:</div><div class="quote"><p>
Also, when it comes to functions having side-effects, you wouldn&#39;t call them in complex expressions even today - at least when the side-effects would concern the same value.
</p></div></div><p>

Except if you don&#39;t know that there is a side effect, or how it works, or what data the side effect handles.</p><p>EDIT:</p><p>I&#39;ve read the examples considering move constructors a thousand times, but I still can&#39;t understand why are they needed. If I wanted to quickly return a vector, I&#39;d return it as a pointer, not as a value type.</p><p>Move semantics is silly and a disaster waiting to happen. It makes an unnecessarily complex language even more complex.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Sun, 10 May 2009 19:29:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you don&#39;t know that you&#39;d be screwed even in today&#39;s C++. (How can you even program anything in any language if you don&#39;t know what&#39;s the effect of the functions you are calling?)</p><p>You seem to have some irrational fears that with C++0x you&#39;d be suddenly forced to give up the common sense that you&#39;ve had so far. Even now you can delete a pointer passed to any function, except you won&#39;t do that because it wouldn&#39;t make sense.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Sun, 10 May 2009 19:39:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>But sometimes the knowledge is not passed from one programmer to the other.</p><p>EDIT:</p><p>My advice is to forget move semantics and go with shared ptrs instead.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Sun, 10 May 2009 19:46:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You still sound a bit like you worried that someone implemented render(BITMAP* buffer) in terms of destroy_bitmap. Common sense tells you that functions shouldn&#39;t have completely unforeseeable side-effects. Unless the purpose of the function is to obliterate an object, it just shouldn&#39;t do it - and the standard seems to have safeguards that this won&#39;t happen by accident.</p><p>shared_ptr is nice but probably not many people would enjoy vector&lt;shared_ptr&lt;string&gt;&gt; or even shared_ptr&lt;vector&lt;shared_ptr&lt;string&gt;&gt;&gt; instead of vector&lt;string&gt;.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Sun, 10 May 2009 20:09:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810899#target">anonymous</a> said:</div><div class="quote"><p>
You still sound a bit like you worried that someone implemented render(BITMAP* buffer) in terms of destroy_bitmap. Common sense tells you that functions shouldn&#39;t have completely unforeseeable side-effects. Unless the purpose of the function is to obliterate an object, it just shouldn&#39;t do it - and the standard seems to have safeguards that this won&#39;t happen by accident.
</p></div></div><p>

Programs are not static entities, they evolve. In the evolution of a program, having to think about copy/move semantics just makes the task more difficult. And it does not scale well.</p><p>For example (I don&#39;t know if this is correct, so I apologize if it is not, but to my current understanding it seems ok):</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> foo<span class="k2">(</span>vector<span class="k3">&lt;</span>int&gt; <span class="k3">&amp;</span>data<span class="k2">)</span> <span class="k2">{</span>
    vector<span class="k3">&lt;</span>int&gt; moved_data <span class="k3">=</span> std::move<span class="k2">(</span>data<span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>

<span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span> <span class="k2">{</span>
    vector<span class="k3">&lt;</span>int&gt; data <span class="k3">=</span> <span class="k2">{</span><span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span><span class="k2">}</span><span class="k2">;</span>
    foo<span class="k2">(</span>data<span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

What happens in the above piece of code? data is emptied at function &#39;foo&#39;. </p><p>Suppose now that the call to foo is deep inside the call stack; a major problem has been created.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
shared_ptr is nice but probably not many people would enjoy vector&lt;shared_ptr&lt;string&gt;&gt; or even shared_ptr&lt;vector&lt;shared_ptr&lt;string&gt;&gt;&gt; instead of vector&lt;string&gt;.
</p></div></div><p>

Typedef is your friend.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Sun, 10 May 2009 20:34:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That function would be broken, unless it clearly indicates that it is supposed to obliterate your vector.</p><p>It&#39;s the same like:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">class</span> Character
<span class="k2">{</span>
    <span class="c">//...</span>
    <span class="k1">void</span> render<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP" target="_blank"><span class="a">BITMAP</span></a><span class="k3">*</span> buffer<span class="k2">)</span>
    <span class="k2">{</span>
        <a href="http://www.allegro.cc/manual/blit" target="_blank"><span class="a">blit</span></a><span class="k2">(</span>image, buffer, ...<span class="k2">)</span><span class="k2">;</span>
        <a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span>buffer<span class="k2">)</span><span class="k2">;</span>
     <span class="k2">}</span>
<span class="k2">}</span><span class="k2">;</span>
</pre></div></div><p>

Suppose this happens to be called deep down in a call stack...</p><p>OK, C++ is &quot;expert friendly&quot; and that is not going to change. You just need to know the consequences of what you are doing, e.g of calling std::move.</p><p>C++0x seems to make it more &quot;expert friendly&quot; in two ways: 1) you need to learn even more to become an &quot;expert&quot;<sup>1</sup>, 2) when you eventually become an &quot;expert&quot;, things look somewhat friendlier.</p><p><sup>1</sup> I&#39;d imagine the leap is not too hard for those that already are &quot;experts&quot; in C++.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Sun, 10 May 2009 20:52:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810906#target">anonymous</a> said:</div><div class="quote"><p>
That function would be broken, unless it clearly indicates that it is supposed to obliterate your vector.
</p></div></div><p>

Broken by what standards? perhaps it&#39;s a legitimate function coded by another programmer in the same project.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
It&#39;s the same like:</p><p>class Character<br />{<br />    //...<br />    void render(BITMAP* buffer)<br />    {<br />        blit(image, buffer, ...);<br />        destroy_bitmap(buffer);<br />     }<br />};</p><p>Suppose this happens to be called deep down in a call stack...
</p></div></div><p>

No, it&#39;s not the same. It&#39;s not always as obvious as in your example.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
OK, C++ is &quot;expert friendly&quot; and that is not going to change. You just need to know the consequences of what you are doing, e.g of calling std::move.
</p></div></div><p>

Perhaps we all need to ditch programming languages and use raw assembly then, which is expert friendly and one should know the consequences of what he is doing.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
C++0x seems to make it more &quot;expert friendly&quot; in two ways: 1) you need to learn even more to become an &quot;expert&quot;1, 2) when you eventually become an &quot;expert&quot;, things look somewhat friendlier.
</p></div></div><p>

Here is another interpretation: C++ lacks garbage collection, languages like Java and C# are faster in certain algorithms due to not excessive copying like C++ does, Stroustrup and Co. are too stubborn to put garbage collection in C++, and therefore the rvalue references+move semantics is born, which simulates pointers while not being pointers.</p><p>The whole problem of copying could have been solved by providing a simple function which moves the contents of one container to another.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Sun, 10 May 2009 22:07:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you move things around incorrectly and in unwanted ways, I suppose it is just as explicit and bad as calling free on a pointer in an arbitrary function (e.g in straight C). Eventually, what language prevents you from clearing the contents of a string, where it shouldn&#39;t be cleared? </p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810914#target">axilmar</a> said:</div><div class="quote"><p>
The whole problem of copying could have been solved by providing a simple function which moves the contents of one container to another. 
</p></div></div><p>

Isn&#39;t std::move exactly that? Except there has to be a way to specify what it means for user-defined objects.</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> foo<span class="k2">(</span>X<span class="k3">&amp;</span><span class="k3">&amp;</span> a<span class="k2">)</span><span class="k2">;</span>
<span class="k1">void</span> foo<span class="k2">(</span>std::auto_ptr<span class="k3">&lt;</span>X&gt; x<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

If I understand correctly, these will not be destructive similarly. In the first case, this will only move from unnamed temporaries, whereas named values will be passed by reference as before.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Here is another interpretation: C++ lacks garbage collection, languages like Java and C# are faster in certain algorithms due to not excessive copying like C++ does, Stroustrup and Co. are too stubborn to put garbage collection in C++, and therefore the rvalue references+move semantics is born, which simulates pointers while not being pointers.
</p></div></div><p>

Quite possible but how many Javas and C#&#39;s do you think we&#39;ll need? I sort of like the deterministic behaviour of C++ programs, which I supposed would be harder to achieve with garbage collection.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Sun, 10 May 2009 22:38:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810925#target">anonymous</a> said:</div><div class="quote"><p>
If you move things around incorrectly and in unwanted ways, I suppose it is just as explicit and bad as calling free on a pointer in an arbitrary function (e.g in straight C). Eventually, what language prevents you from clearing the contents of a string, where it shouldn&#39;t be cleared?
</p></div></div><p>

You should consider the problem in the context of a group of people and code evolving over the years. For a single person and a few thousands of lines of code, the problem is small. But as the code grows larger, and more people are involved, these little changes do not scale well.</p><p>Do you know about the auto_ptr fiasco? people did not use it because of the problems it introduces, i.e. wrongful destruction of objects, especially in STL containers.</p><p>Move semantics are bad. If you read the literature about destructive updating, the academia considers it bad. Imagine then what destructive reading is.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Isn&#39;t std::move exactly that? Except there has to be a way to specify what it means for user-defined objects.
</p></div></div><p>

It is, but it could have been introduced without a new type of reference.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Quite possible but how many Javas and C#&#39;s do you think we&#39;ll need? I sort of like the deterministic behaviour of C++ programs, which I supposed would be harder to achieve with garbage collection. 
</p></div></div><p>

Nope, it is not. Check out my collector here: <a href="http://www.boostpro.com/vault/index.php?action=downloadfile&amp;filename=gc1.zip&amp;directory=Memory&amp;">gc1.zip</a></p><p>Boost members don&#39;t want garbage collection, even if it is 100% a library solution, and even if it solves the problem of finalization...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Mon, 11 May 2009 00:58:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m not sure I quite understand the difference between copy and move for a stack allocated object... <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Mon, 11 May 2009 01:32:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810947#target">axilmar</a> said:</div><div class="quote"><p>
It is, but it could have been introduced without a new type of reference.
</p></div></div><p>

It seems that the new kind of reference (which mostly has to do with binding to temporaries) behaves quite differently from auto_ptr. </p><p>Or, probably all the people behind the standards committee are all just a bunch of lunatics: they realize the problems with std::auto_ptr and deprecate that(?) and then go on to introduce an even more hideous feature with all the same problems and many more!</p><p>I&#39;m still not quite sure, though, how a misplaced std::move would be more likely than a misplaced delete, free or destroy_bitmap.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Nope, it is not. Check out my collector here
</p></div></div><p>

It&#39;s interesting but am I not supposed to get the destructor message printed from this code?</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span> <span class="k2">{</span>
    gc_ptr<span class="k3">&lt;</span>Foo&gt; p <span class="k3">=</span> gc_new Foo<span class="k2">;</span>
    <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810953#target">bamccaig</a> said:</div><div class="quote"><p>
I&#39;m not sure I quite understand the difference between copy and move for a stack allocated object...
</p></div></div><p>

If you mean something like an int, then move is probably same as copy.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Mon, 11 May 2009 03:50:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>How could it be otherwise?  Every possible combination of bits in a 32 bit word maps to a valid long int.  There&#39;s no way to mark it as an &quot;invalid int&quot; except to make it non-readable memory, which would affect the neighbors.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Mon, 11 May 2009 04:00:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810978#target">anonymous</a> said:</div><div class="quote"><p>
It seems that the new kind of reference (which mostly has to do with binding to temporaries) behaves quite differently from auto_ptr.
</p></div></div><p>

It&#39;s not the rvalue references that behave differently from auto_ptr, it&#39;s that they are redundant in the context of the move operation (which is the only reason they were introduced in the first place).</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Or, probably all the people behind the standards committee are all just a bunch of lunatics: they realize the problems with std::auto_ptr and deprecate that(?) and then go on to introduce an even more hideous feature with all the same problems and many more!
</p></div></div><p>

Or they simply wanted the STL to win back the benchmark race from Java and C#.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I&#39;m still not quite sure, though, how a misplaced std::move would be more likely than a misplaced delete, free or destroy_bitmap.
</p></div></div><p>

A lot more likely, because of the nature of the operation: programmers will try to &#39;optimize&#39; the code by inserting move operations here and there, and then other programmers that their code will shoot their feet with that code.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
It&#39;s interesting but am I not supposed to get the destructor message printed from this code?
</p></div></div><p>

Only if the object is garbage collected.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810953#target">bamccaig</a> said:</div><div class="quote"><p>
I&#39;m not sure I quite understand the difference between copy and move for a stack allocated object...
</p></div></div><p>

It&#39;s not for stack-allocated objects, it&#39;s for the contents of stack-allocated objects that are allocated on the heap.</p><p>In short, in current C++ many containers are passed as &#39;const&#39; in functions, and their contents need to be duplicated. This has a high performance cost. By moving the containers instead of copying them, the code would be faster.</p><p>All of this is because copying is expensive, moving is not. Of course, you could always return a pointer, but please don&#39;t tell the C++ committee that...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Mon, 11 May 2009 04:04:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810978#target">anonymous</a> said:</div><div class="quote"><p>If you mean something like an int, then move is probably same as copy.</p></div></div><p>
Even for a complex user-defined type. What&#39;s the difference? It doesn&#39;t make sense that it could cause problems to me. It&#39;s either going to copy the object or a pointer to it. There&#39;s no way to move the memory cells. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><p>Maybe I should just RTFM... <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Mon, 11 May 2009 04:06:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>For example, if you have a std::string (or any pimpl object), the move constructor would look like this:</p><div class="source-code snippet"><div class="inner"><pre>std::string<span class="k2">(</span>std::string<span class="k3">&amp;</span><span class="k3">&amp;</span> source<span class="k2">)</span>
<span class="k2">{</span>
    pimp_string <span class="k3">=</span> source.pimp_string<span class="k2">;</span>
    source.pimp_string <span class="k3">=</span> nullptr<span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

It could be used to prolong the lifetime of a temporaries (or rather move the pointer over from one temporary to another without any memory allocations or deallocations) in statements like:</p><div class="source-code snippet"><div class="inner"><pre>s <span class="k3">=</span> s1 <span class="k3">+</span> s2 <span class="k3">+</span> s3 <span class="k3">+</span> s4 <span class="k3">+</span> s5<span class="k2">;</span>
</pre></div></div><p>

It is supposed to be mostly for moving around temporaries, that you can&#39;t have any other references to anyway. To move around named object, you&#39;ll need to be more explicit about it.</p><p>Anyway, it is (going to be) available in VC10 and GCC 4.3, and it is probably a bit hard to learn about theoretically without the means of actually trying things out.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810981#target">axilmar</a> said:</div><div class="quote"><p>
A lot more likely, because of the nature of the operation: programmers will try to &#39;optimize&#39; the code by inserting move operations here and there, and then other programmers that their code will shoot their feet with that code.
</p></div></div><p>

Sadly, C++ doesn&#39;t support voodoo programming that well, even without C++0x. I still get the impression that you expect people to go completely crazy and lose common sense overnight - but I&#39;m not a professional, so what do I know...</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Only if the object is garbage collected.
</p></div></div><p>

So in that simple program the object was not collected?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Mon, 11 May 2009 04:26:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810288#target">BAF</a> said:</div><div class="quote"><p>
making junk like {} useless.
</p></div></div><p>
The {} &quot;junk&quot; is one of the best features of 0x.  Clearly you do not understand its value, as there is no popular language with a remotely similar feature.</p><p>You guys should send Bjarne an email  with some of your opinions (despite most of them being very short-sighted and, lets be frank, stupid).  He answers and responds to most emails.</p><p>A lot of the time C++ gets caught up these arguments of <i>&quot;should languages be designed for just smart people or should they include dumb people?&quot;</i>  If you feel it should include dumb people, say so.  Don&#39;t project that motivation onto its features, which many very intelligent people appreciate.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Mon, 11 May 2009 11:04:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/810988#target">anonymous</a> said:</div><div class="quote"><p>
Sadly, C++ doesn&#39;t support voodoo programming that well, even without C++0x. I still get the impression that you expect people to go completely crazy and lose common sense overnight - but I&#39;m not a professional, so what do I know...
</p></div></div><p>

It seems you are entangled in your own thoughts about common sense and stuff. Have you ever worked in a team were each programmer develops a different part of the program? I am not saying that people will lose common sense, I am saying that moving data around might make things a hell of lot more complicated than they already are.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
So in that simple program the object was not collected? 
</p></div></div><p>

Not if you don&#39;t invoke the collector (it&#39;s test code to prove that destructors and gc play well).</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811042#target">Dustin Dettmer</a> said:</div><div class="quote"><p>
You guys should send Bjarne an email with some of your opinions (despite most of them being very short-sighted and, lets be frank, stupid). He answers and responds to most emails.
</p></div></div><p>

He responds, but you&#39;ll achieve nothing. The best he will say is &#39;perhaps for the next standard&#39;.</p><p>{} is stupid, but it is stupid because the normal construction does not work as it should work.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Mon, 11 May 2009 12:25:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811057#target">axilmar</a> said:</div><div class="quote"><p>
It seems you are entangled in your own thoughts about common sense and stuff. Have you ever worked in a team were each programmer develops a different part of the program? I am not saying that people will lose common sense, I am saying that moving data around might make things a hell of lot more complicated than they already are.
</p></div></div><p>

I haven&#39;t, so you perhaps you are right.</p><p>However, I still don&#39;t see how it can make it that much more complicated given that there are countless ways to screw up (and not just in C++). As you said, moving can already be implemented with existing language features. Why aren&#39;t people already moving things around? OK, perhaps it just hasn&#39;t occurred to them that this could be done. But if you stay away from std::move, these references are supposed to move around only unnamed temporaries?</p><p>Reading more on the issue, there seem to be some potential annoyances:</p><p>1) It seems move constructors and move assignment will not be automatically generated. So, if you compose your classes of RAII components, this means some rather repetitious  coding if you want this to happen:</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><span class="k1">class</span> Person
<span class="number">  2</span><span class="k2">{</span>
<span class="number">  3</span>    string first_name, last_name<span class="k2">;</span>
<span class="number">  4</span>    <span class="c">//...</span>
<span class="number">  5</span>    Person<span class="k2">(</span>Person<span class="k3">&amp;</span><span class="k3">&amp;</span> p<span class="k2">)</span><span class="k2">:</span> 
<span class="number">  6</span>        first_name<span class="k2">(</span>move<span class="k2">(</span>p.first_name<span class="k2">)</span>, 
<span class="number">  7</span>        last_name<span class="k2">(</span>move<span class="k2">(</span>p.last_name<span class="k2">)</span>
<span class="number">  8</span>    <span class="k2">{</span><span class="k2">}</span>
<span class="number">  9</span>    Person<span class="k3">&amp;</span> <span class="k1">operator</span><span class="k3">=</span><span class="k2">(</span>Person<span class="k3">&amp;</span><span class="k3">&amp;</span> rhv<span class="k2">)</span>
<span class="number"> 10</span>    <span class="k2">{</span>
<span class="number"> 11</span>        first_name <span class="k3">=</span> move<span class="k2">(</span>rhv.first_name<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 12</span>        last_name <span class="k3">=</span> move<span class="k2">(</span>rhv.last_name<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 13</span>        <span class="k1">return</span> <span class="k3">*</span><span class="k1">this</span><span class="k2">;</span>
<span class="number"> 14</span>    <span class="k2">}</span>
<span class="number"> 15</span><span class="k2">}</span>
</div></div><p>

2) It seems that there may be an explosion of overloads (if you want to make a super-fast library). E.g there would be swap(T&amp;, T&amp;), swap(T&amp;&amp;, T&amp;) and swap(T&amp;, T&amp;&amp;) (it wouldn&#39;t make sense to swap two temporaries).</p><p>I also looked at the draft and counted 7 new overloads for string::operator+ in addition to the existing 5 overloads.</p><p>Everywhere you have const T&amp; now, you&#39;ll need an overload with T&amp;&amp; (if you want to provide for nameless temporaries).</p><p>It will give some work to library writers, but I suppose cases where you would implement this amount of overloads are limited. (I think I&#39;m planning to take advantage of this rather passively - this should benefit STL a lot, there might be a few places where I&#39;d use it myself, but most of the code would still be as before.)</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Not if you don&#39;t invoke the collector (it&#39;s test code to prove that destructors and gc play well).
</p></div></div><p>

Ok. So anything that is still in scope needs to be zeroed explicitly and _collect needs to be called?</p><p>It&#39;s all rather impressive but doesn&#39;t it mean that only one kind of shared ownership is forced on me? I&#39;d still use a weak_ptr if some object is to be in control of how long something stays alive? Eventually, wouldn&#39;t I just end up using a large variety of resource management systems (automatic, weak_ptr, scoped_ptr, gc_ptr and perhaps some libraries which want to manage pointers for you in their own way) as before?</p><p>Nah, that&#39;s probably just your point (shared_ptr for everyone - without worries of cycles) and may be good enough for many things. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
{} is stupid, but it is stupid because the normal construction does not work as it should work.
</p></div></div><p>

It seems to me that the sole motivation is not the &quot;most vexing parse&quot; (and default constructors).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Mon, 11 May 2009 20:52:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><i>Initial quote removed to cut back on post length</i></p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811057#target">axilmar</a> said:</div><div class="quote"><p>
He responds, but you&#39;ll achieve nothing. The best he will say is &#39;perhaps for the next standard&#39;.
</p></div></div><p>
Actually, he responds with an intelligent reply that is rationally constructed and has accurate information about language design.  Can you say that about the haters around here?</p><p>Below is taken from <a href="http://www.research.att.com/~bs/C++0xFAQ.html">C++0x FAQ</a> by Bjarne Stroustrup.</p><div class="quote_container"><div class="title">axilmar said:</div><div class="quote"><p>
{} is stupid, but it is stupid because the normal construction does not work as it should work.
</p></div></div><p>
</p><div class="quote_container"><div class="title">Bjarne Stroustrup said:</div><div class="quote"><p>
<b>Initializer lists</b></p><p>Consider
</p><div class="source-code snippet"><div class="inner"><pre>  vector<span class="k3">&lt;</span>double&gt; v <span class="k3">=</span> <span class="k2">{</span> <span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>.<span class="n">456</span>, <span class="n">99</span>.<span class="n">99</span> <span class="k2">}</span><span class="k2">;</span>
  list<span class="k3">&lt;</span>pair<span class="k3">&lt;</span>string,string&gt;&gt; languages <span class="k3">=</span> <span class="k2">{</span>
    <span class="k2">{</span><span class="s">"Nygaard"</span>,<span class="s">"Simula"</span><span class="k2">}</span>, <span class="k2">{</span><span class="s">"Richards"</span>,<span class="s">"BCPL"</span><span class="k2">}</span>, <span class="k2">{</span><span class="s">"Ritchie"</span>,<span class="s">"C"</span><span class="k2">}</span>
  <span class="k2">}</span><span class="k2">;</span> 
  map<span class="k3">&lt;</span>vector<span class="k3">&lt;</span>string&gt;,vector<span class="k3">&lt;</span>int&gt;&gt; years <span class="k3">=</span> <span class="k2">{</span>
    <span class="k2">{</span> <span class="k2">{</span><span class="s">"Maurice"</span>,<span class="s">"Vincent"</span>, <span class="s">"Wilkes"</span><span class="k2">}</span>,<span class="k2">{</span><span class="n">1913</span>, <span class="n">1945</span>, <span class="n">1951</span>, <span class="n">1967</span>, <span class="n">2000</span><span class="k2">}</span> <span class="k2">}</span>,
    <span class="k2">{</span> <span class="k2">{</span><span class="s">"Martin"</span>, <span class="s">"Ritchards"</span><span class="k2">}</span> <span class="k2">{</span><span class="n">1982</span>, <span class="n">2003</span>, <span class="n">2007</span><span class="k2">}</span> <span class="k2">}</span>, 
    <span class="k2">{</span> <span class="k2">{</span><span class="s">"David"</span>, <span class="s">"John"</span>, <span class="s">"Wheeler"</span><span class="k2">}</span>, <span class="k2">{</span><span class="n">1927</span>, <span class="n">1947</span>, <span class="n">1951</span>, <span class="n">2004</span><span class="k2">}</span> <span class="k2">}</span>
  <span class="k2">}</span><span class="k2">;</span>
</pre></div></div><p>
Initializer lists are not just for arrays any more. The mechanism for accepting a {}-list is a function (often a constructor) accepting an argument of type std::initializer_list&lt;T&gt;. For example:
</p><div class="source-code snippet"><div class="inner"><pre>  <span class="k1">void</span> f<span class="k2">(</span>initializer_list<span class="k3">&lt;</span>int&gt;<span class="k2">)</span><span class="k2">;</span>
  f<span class="k2">(</span><span class="k2">{</span><span class="n">1</span>,<span class="n">2</span><span class="k2">}</span><span class="k2">)</span><span class="k2">;</span>
  f<span class="k2">(</span><span class="k2">{</span><span class="n">23</span>,<span class="n">345</span>,<span class="n">4567</span>,<span class="n">56789</span><span class="k2">}</span><span class="k2">)</span><span class="k2">;</span>
  f<span class="k2">(</span><span class="k2">{</span><span class="k2">}</span><span class="k2">)</span><span class="k2">;</span>  <span class="c">// the empty list</span>
  f<span class="k2">{</span><span class="n">1</span>,<span class="n">2</span><span class="k2">}</span><span class="k2">;</span>  <span class="c">// error: function call ( ) missing</span>

  years.insert<span class="k2">(</span><span class="k2">{</span><span class="k2">{</span><span class="s">"Bjarne"</span>,<span class="s">"Stroustrup"</span><span class="k2">}</span>,<span class="k2">{</span><span class="n">1950</span>, <span class="n">1975</span>, <span class="n">1985</span><span class="k2">}</span><span class="k2">}</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
The initializer list can be arbitrary length, but must be homogeneous (all elements of a the template argument type, T, or convertable to T).</p><p>A container might implement an initializer-list constructor like this:
</p><div class="source-code snippet"><div class="inner"><pre>  <span class="k1">template</span><span class="k3">&lt;</span><span class="k1">class</span> E&gt; <span class="k1">class</span> vector <span class="k2">{</span>
  public:
       vector <span class="k2">(</span>std::initializer_list<span class="k3">&lt;</span>E&gt; s<span class="k2">)</span> <span class="c">// initializer-list constructor</span>
       <span class="k2">{</span>
          reserve<span class="k2">(</span>s.size<span class="k2">(</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>  <span class="c">// get the right amount of space</span>
          uninitialized_copy<span class="k2">(</span>s.begin<span class="k2">(</span><span class="k2">)</span>, s.end<span class="k2">(</span><span class="k2">)</span>, elem<span class="k2">)</span><span class="k2">;</span>  <span class="c">// initialize elements (in elem[0:s.size()))</span>
      sz <span class="k3">=</span> s.size<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>  <span class="c">// set vector size</span>
       <span class="k2">}</span>
     
    <span class="c">// ... as before ...</span>
  <span class="k2">}</span><span class="k2">;</span>
</pre></div></div><p>
The distinction between direct initialization and copy initialization is maintained for { } initialization, but becomes relevant less frequently because of { } initialization. For example, std::vector has an explicit constructor from int and an initializer-list constructor:
</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span>  vector<span class="k3">&lt;</span>double&gt; v1<span class="k2">(</span><span class="n">7</span><span class="k2">)</span><span class="k2">;</span>  <span class="c">// ok: v1 has 7 elements</span>
<span class="number">  2</span>  v1 <span class="k3">=</span> <span class="n">9</span><span class="k2">;</span>      <span class="c">// error: no conversion from int to vector</span>
<span class="number">  3</span>  vector<span class="k3">&lt;</span>double&gt; v2 <span class="k3">=</span> <span class="n">9</span><span class="k2">;</span>  <span class="c">// error: no conversion from int to vector</span>
<span class="number">  4</span>
<span class="number">  5</span>  <span class="k1">void</span> f<span class="k2">(</span><span class="k1">const</span> vector<span class="k3">&lt;</span>double&gt;<span class="k3">&amp;</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  6</span>  f<span class="k2">(</span><span class="n">9</span><span class="k2">)</span><span class="k2">;</span>        <span class="c">// error: no conversion from int to vector</span>
<span class="number">  7</span>
<span class="number">  8</span>  vector<span class="k3">&lt;</span>double&gt; v1<span class="k2">{</span><span class="n">7</span><span class="k2">}</span><span class="k2">;</span>    <span class="c">// ok: v1 has 1 element (with its value 7)</span>
<span class="number">  9</span>  v1 <span class="k3">=</span> <span class="k2">{</span><span class="n">9</span><span class="k2">}</span><span class="k2">;</span>      <span class="c">// ok v1 now has 1 element (with its value 9)</span>
<span class="number"> 10</span>  vector<span class="k3">&lt;</span>double&gt; v2 <span class="k3">=</span> <span class="k2">{</span><span class="n">9</span><span class="k2">}</span><span class="k2">;</span>  <span class="c">// ok: v2 has 1 element (with its value 9)</span>
<span class="number"> 11</span>  f<span class="k2">(</span><span class="k2">{</span><span class="n">9</span><span class="k2">}</span><span class="k2">)</span><span class="k2">;</span>        <span class="c">// ok: f is called withthe list { 9 }</span>
<span class="number"> 12</span>
<span class="number"> 13</span>  vector<span class="k3">&lt;</span>vector<span class="k3">&lt;</span>double&gt;&gt; vs <span class="k3">=</span> <span class="k2">{</span>
<span class="number"> 14</span>    vector<span class="k3">&lt;</span>double&gt;<span class="k2">(</span><span class="n">10</span><span class="k2">)</span>,   <span class="c">// ok: explicit construction (10 elements)</span>
<span class="number"> 15</span>    vector<span class="k3">&lt;</span>double&gt;<span class="k2">{</span><span class="n">10</span><span class="k2">}</span>,  <span class="c">// ok explicit construction (1 element with the value 10)</span>
<span class="number"> 16</span>    <span class="n">10</span>       <span class="c">// error: vector's constructor is explicit</span>
<span class="number"> 17</span>  <span class="k2">}</span><span class="k2">;</span>
</div></div><p>
The function can access the initializer_list as an immutable sequence. For example:
</p><div class="source-code snippet"><div class="inner"><pre>  <span class="k1">void</span> f<span class="k2">(</span>initializer_list<span class="k3">&lt;</span>int&gt; args<span class="k2">)</span>
  <span class="k2">{</span>
    <span class="k1">for</span> <span class="k2">(</span><span class="k1">auto</span> p<span class="k3">=</span>args.begin<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span> p<span class="k3">!</span><span class="k3">=</span>args.end<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span> <span class="k3">+</span><span class="k3">+</span>p<span class="k2">)</span> cout <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="k3">*</span>p <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"\n"</span><span class="k2">;</span>
  <span class="k2">}</span>
</pre></div></div><p>
A constructor that takes a single argument of type std::initializer_list is called an initializer-list constructor.</p><p>The standard library containers, string, and regex have initializer-list constructors, assignment, etc. An initializer-list can be used as a Range, e.g. in a range for statement</p><p>The initializer lists are part of the scheme for uniform and general initialization.
</p></div></div><p><span class="ref"><sup>[<a href="#">1</a>]</sup></span></p><div class="quote_container"><div class="title">Bjarne Stroustrup said:</div><div class="quote"><p>
<b>Rvalue references</b> (Aka Move Semantics)</p><p>The distinction between lvalues (what can be used on the left-hand side of an assignment) and rvalues (what can be used on the right-hand side of an assignment) goes back to Christopher Strachey (the father of C++ ancestor CPL and of denotational semantics). In C++, non-const references can bind to lvalues, const references to lvalues or rvalues, but there is nothing that can bind to a non-const rvalue. That&#39;s to protect people from changing the values of temporaries that are destroyed before their new value can be used. For example:
</p><div class="source-code snippet"><div class="inner"><pre>  <span class="k1">void</span> incr<span class="k2">(</span><span class="k1">int</span><span class="k3">&amp;</span> a<span class="k2">)</span> <span class="k2">{</span> <span class="k3">+</span><span class="k3">+</span>a<span class="k2">;</span> <span class="k2">}</span>
  <span class="k1">int</span> i <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
  incr<span class="k2">(</span>i<span class="k2">)</span><span class="k2">;</span>  <span class="c">// i becomes 1</span>
  incr<span class="k2">(</span><span class="n">0</span><span class="k2">)</span><span class="k2">;</span>  <span class="c">// error: 0 in not an lvalue</span>
</pre></div></div><p>
If that incr(0)) was allowed either some temporary that nobody ever saw would be incremented or - far worse - the value of 0 would become 1. The latter sounds silly, but there was actually a bug like that in early Fortran compilers that set aside a memory location to hold the value 0.</p><p>So far, so good, but consider
</p><div class="source-code snippet"><div class="inner"><pre>  <span class="k1">template</span><span class="k3">&lt;</span><span class="k1">class</span> T&gt; swap<span class="k2">(</span>T<span class="k3">&amp;</span> a, T<span class="k3">&amp;</span> b<span class="k2">)</span>    <span class="c">// "old style swap"</span>
  <span class="k2">{</span>
    T tmp<span class="k2">(</span>a<span class="k2">)</span><span class="k2">;</span>  <span class="c">// now we have two copies of a</span>
    a <span class="k3">=</span> b<span class="k2">;</span>    <span class="c">// now we have two copies of b</span>
    b <span class="k3">=</span> tmp<span class="k2">;</span>  <span class="c">// now we have two copies of tmp (aka a)</span>
  <span class="k2">}</span>
</pre></div></div><p>
If T is a type for which it can be expensive to copy elements, such as string and vector, swap becomes an expensive operation (for the standard library, we have specializations of string and vector swap() to deal with that). Note something curious: We didn&#39;t want any copies at all. We just wanted to move the values of a, b, and tmp around a bit.</p><p>In C++0x, we can define &quot;move constructors&quot; and &quot;move assignments&quot; to move rather than copy their argument:
</p><div class="source-code snippet"><div class="inner"><pre>  <span class="k1">template</span><span class="k3">&lt;</span><span class="k1">class</span> T&gt; <span class="k1">class</span> vector <span class="k2">{</span>
    <span class="c">// ...</span>
    vector<span class="k2">(</span><span class="k1">const</span> vector<span class="k3">&amp;</span><span class="k2">)</span><span class="k2">;</span>       <span class="c">// copy constructor</span>
    vector<span class="k2">(</span>vector<span class="k3">&amp;</span><span class="k3">&amp;</span><span class="k2">)</span><span class="k2">;</span>       <span class="c">// move constructor</span>
    vector<span class="k3">&amp;</span> <span class="k1">operator</span><span class="k3">=</span><span class="k2">(</span><span class="k1">const</span> vector<span class="k3">&amp;</span><span class="k2">)</span><span class="k2">;</span>  <span class="c">// copy assignment</span>
    vector<span class="k3">&amp;</span> <span class="k1">operator</span><span class="k3">=</span><span class="k2">(</span>vector<span class="k3">&amp;</span><span class="k3">&amp;</span><span class="k2">)</span><span class="k2">;</span>    <span class="c">// move assignment</span>
  <span class="k2">}</span><span class="k2">;</span>  <span class="c">// note: move constructor and move assignment takes non-const &amp;&amp;</span>
    <span class="c">// they can, and usually do, write to their argument</span>
</pre></div></div><p>
The &amp;&amp; indicates an &quot;rvalue reference&quot;. An rvalue reference can bind to either an rvalue or an lvalue:
</p><div class="source-code snippet"><div class="inner"><pre>  X a<span class="k2">;</span>
  X f<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
  X<span class="k3">&amp;</span> r1 <span class="k3">=</span> a<span class="k2">;</span>    <span class="c">// bind r1 to a (an lvalue)</span>
  X<span class="k3">&amp;</span> r2 <span class="k3">=</span> f<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>    <span class="c">// error: f() is an rvalue; can't bind</span>

  X<span class="k3">&amp;</span><span class="k3">&amp;</span> rr1 <span class="k3">=</span> f<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>  <span class="c">// fine: bind rr1 to temporary</span>
  X<span class="k3">&amp;</span><span class="k3">&amp;</span> rr2 <span class="k3">=</span> a<span class="k2">;</span>  <span class="c">// also fine: bind rr2 to a (an lvalue)</span>
</pre></div></div><p>
The idea behind a move assignment is that instead of making a copy, it simply takes the representation from its source and replaces it with a cheap default. For example, for strings s1=s2 using the move assignment would not make a copy of s2&#39;s characters; instead, it would just let s1 treat those characters as its own and somehow delete s1&#39;s old characters (maybe by leaving them in s2, which presumably are just about to be destroyed).</p><p>How do we know whether it&#39;s ok to simply move from a source. We tell the compiler:
</p><div class="source-code snippet"><div class="inner"><pre>  <span class="k1">template</span><span class="k3">&lt;</span><span class="k1">class</span> T&gt; 
  <span class="k1">void</span> swap<span class="k2">(</span>T<span class="k3">&amp;</span> a, T<span class="k3">&amp;</span> b<span class="k2">)</span>  <span class="c">// "perfect swap" (almost)</span>
  <span class="k2">{</span>
    T tmp <span class="k3">=</span> move<span class="k2">(</span>a<span class="k2">)</span><span class="k2">;</span>  <span class="c">// could invalidate a</span>
    a <span class="k3">=</span> move<span class="k2">(</span>b<span class="k2">)</span><span class="k2">;</span>  <span class="c">// could invalidate b</span>
    b <span class="k3">=</span> move<span class="k2">(</span>tmp<span class="k2">)</span><span class="k2">;</span>  <span class="c">// could invalidate tmp</span>
  <span class="k2">}</span>
</pre></div></div><p>
move(x) means &quot;you can treat x as an rvalue&quot;. Maybe it would have been better if move() had been called rval(), but by now move() has been used for years. The move() template function can be written in C++0x (see the &quot;brief introduction&quot;) and and uses rvalue references.</p><p>The old void swap(T&amp; a, T&amp; b) still requires lvalues. Now, we can do better, so C++0x provides:
</p><div class="source-code snippet"><div class="inner"><pre>  <span class="k1">template</span><span class="k3">&lt;</span><span class="k1">class</span> T&gt; <span class="k1">void</span> swap<span class="k2">(</span>T<span class="k3">&amp;</span><span class="k3">&amp;</span> a, T<span class="k3">&amp;</span> b<span class="k2">)</span><span class="k2">;</span>
  <span class="k1">template</span><span class="k3">&lt;</span><span class="k1">class</span> T&gt; <span class="k1">void</span> swap<span class="k2">(</span>T<span class="k3">&amp;</span> a, T<span class="k3">&amp;</span><span class="k3">&amp;</span> b<span class="k2">)</span><span class="k2">;</span>
  <span class="k1">template</span><span class="k3">&lt;</span><span class="k1">class</span> T&gt; <span class="k1">void</span> swap<span class="k2">(</span>T<span class="k3">&amp;</span> a, T<span class="k3">&amp;</span> b<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
Given those, we can swap an lvalue with an rvalue
</p><div class="source-code snippet"><div class="inner"><pre>  vector<span class="k3">&lt;</span>double&gt; v <span class="k3">=</span> <span class="k2">{</span><span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>, <span class="n">4</span>, <span class="n">5</span>, <span class="n">6</span> <span class="k2">}</span>
  swap<span class="k2">(</span>v,<span class="k2">{</span><span class="k2">}</span><span class="k2">)</span><span class="k2">;</span>  <span class="c">// clear v</span>
      <span class="c">// v's old elements are implicitly deleted</span>
</pre></div></div><p>
Rvalue references can also be used to provide perfect forwarding.</p><p>In the C++0x standard library, all containers are provided with move constructors and move assignment and operations that insert new elements, such as insert() and push_back() have versions that take rvalue references. The net result is that the standard containers and algorithms quietly - without user intervention - improve in performance because they copy less.</p><p>Caveat: there is an open issue on whether an rvalue reference should be able to bind to an lvalue. The use of move() and swap() above would not be affected by such a change, but the implementations and overload sets of some library facilities would be (see N2812=08-0322). 
</p></div></div><p><span class="ref"><sup>[<a href="#">2</a>]</sup></span>
</p><div class="ref-block"><h2>References</h2><ol><li><a href="http://www.research.att.com/~bs/C++0xFAQ.html#think">http://www.research.att.com/~bs/C++0xFAQ.html#think</a></li><li><a href="http://www.research.att.com/~bs/C++0xFAQ.html#rval">http://www.research.att.com/~bs/C++0xFAQ.html#rval</a></li></ol></div></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Mon, 11 May 2009 22:07:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Dustin Dettmer,</p><p>thank you, very enlightening posts.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811120#target">Dustin Dettmer</a> said:</div><div class="quote"><p>
Can you say that about the haters around here?
</p></div></div><p>

If you refer to the other thread about nuking the USA, don&#39;t pay attention to silly things like that.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Initializer lists are not just for arrays any more.
</p></div></div><p>
 <br />But the lists have to be homogeneous...which is a lost chance for doing something like this:</p><div class="source-code snippet"><div class="inner"><pre>Button <span class="k3">*</span>btn <span class="k3">=</span> <span class="k1">new</span> Window<span class="k2">(</span><span class="k2">{</span><span class="s">"Close"</span>, bind<span class="k2">(</span><span class="k3">&amp;</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_104.html" target="_blank">close</a><span class="k2">)</span><span class="k2">}</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

An initializer list is a subset of tuple. They should have formalized tuple syntax...a tuple {x, y ... z} where all the members are of the same type is an initializer list.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Caveat: there is an open issue on whether an rvalue reference should be able to bind to an lvalue. 
</p></div></div><p>

Big caveat in my opinion.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Tue, 12 May 2009 02:00:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811178#target">axilmar</a> said:</div><div class="quote"><p>
But the lists have to be homogeneous...which is a lost chance for doing something like this:
</p></div></div><p>

But the constructor for Window doesn&#39;t have to take a std::initializer_list?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Tue, 12 May 2009 02:29:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>axilmar seems to be complaining that you can&#39;t do stuff like this:</p><div class="source-code snippet"><div class="inner"><pre><span class="p">#include &lt;tuple&gt;</span>

<span class="k1">int</span> test<span class="k2">(</span>std::tuple<span class="k3">&lt;</span><span class="k1">int</span>, float&gt; t<span class="k2">)</span>
<span class="k2">{</span>
    <span class="k1">return</span> std::get<span class="k3">&lt;</span><span class="n">0</span><span class="k3">&gt;</span><span class="k2">(</span>t<span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>

<span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span>
<span class="k2">{</span>
    test<span class="k2">(</span>std::make_tuple<span class="k2">(</span><span class="n">5</span>, <span class="n">3</span>.<span class="n">05f</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span><span class="c">//works fine</span>
    test<span class="k2">(</span><span class="k2">{</span><span class="n">5</span>, <span class="n">3</span>.<span class="n">05f</span><span class="k2">}</span><span class="k2">)</span><span class="k2">;</span><span class="c">//errors, but theoretically a desired sort of syntax</span>

    <span class="k1">return</span> <span class="n">1</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

In principle, the functionality desired is there, just using a substandard syntax.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Tue, 12 May 2009 03:14:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811189#target">SiegeLord</a> said:</div><div class="quote"><p>
In principle, the functionality desired is there, just using a substandard syntax. 
</p></div></div><p>

Yeap, that&#39;s it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Tue, 12 May 2009 03:16:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811178#target">axilmar</a> said:</div><div class="quote"><p>
</p><div class="quote_container"><div class="title">Me said:</div><div class="quote"><p>
Can you say that about the haters around here?
</p></div></div><p>
If you refer to the other thread about nuking the USA, don&#39;t pay attention to silly things like that.
</p></div></div><p>
I meant the people in this thread.  But I was overreacting a bit anyway <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><p>There is this movement among people to hate C++ for illogical and bizarre reasons.  It struck a cord in me, hearing people be so dismissive towards it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Tue, 12 May 2009 10:00:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811223#target">Dustin Dettmer</a> said:</div><div class="quote"><p>
There is this movement among people to hate C++ for illogical and bizarre reasons.
</p></div></div><p>
Personally, I don&#39;t hate C++. At all. I just see myself using it less and less, because its relative advantages over other languages (runtime performance, detailed low-level control, manual memory management) are, for my purposes, being outweighed by its disadvantages (less comfortable syntax, tedious header / implementation separation, limited standard libraries, platform specific issues, diverging coding standards, manual memory management); and from what I read here, C++0x isn&#39;t going to make things much better. The new features seem to open doors to yet more of those &quot;most obscure syntax to achieve everything in one line of code&quot; contests, instead of stimulating best practices and maintainable, readable code.<br />But then, C++ shouldn&#39;t be competing with Java or C# anyway, so maybe this is a good thing. After all, C++ is not the general purpose programming language of the future, it is the programming language of choice for applications where low-level access and runtime performance are the most important decision factors, but where a high level of organisation is still desired because of the complex nature of the problem, or the sheer size of the project and / or team.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Tue, 12 May 2009 12:06:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Am mentioned in the other thread. Hate is a strong word. And we use it too much. Mostly people saying &quot;I hate&quot; instead of &quot;I don&#39;t like&quot;. Id do this sometimes, too. It&#39;s not good. But easy on a platform where you&#39;re hidden.</p><p>It&#39;s like Mircrosoft. Their software isn&#39;t that bad but often hated, because they are dominating the market. The letter C is dominating the Market, too. In different forms ( C, C++, C#, Objective-C, Java ). C-ish languages aren&#39;t bad. But there are other languages out there which aren&#39;t bad, too. But they are ignored by the community. Even the newer ones ( C# ) are fought.</p><p>An example:</p><p>Apple decided to use smalltalk syntax. But instead of using this nice language they created this monster, called Objective-C, mixing two really different syntaxes for C compatibility. Why they don&#39;t create a smalltalk compiler, able to create fast executables, instead?</p><p>So you can say there&#39;s movement among people to love C++ for illogical and bizarre reasons. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Martin Kalbfuß)</author>
		<pubDate>Tue, 12 May 2009 14:00:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Curly-bracket languages (the &quot;C-ish&quot; ones) dominate the scene for one simple reason: They are similar enough to make the transition between them ridiculously easy. <br />When I learned C (after Pascal and some Basic) it took me about a year or so to really become productive. <br />I picked up C# in about a week to a comparable level - enough to pass a test and get hired as a C# developer anyway. I don&#39;t think I&#39;d be able to pull this off with, say, Haskell.</p><p>In business terms; when your developers need to learn a new language, it is cheaper to pick one that resembles what they already know. And they are very likely to know some kind of curly-bracket language.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Tue, 12 May 2009 15:51:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811246#target">Martin Kalbfuß</a> said:</div><div class="quote"><p>Apple decided to use smalltalk syntax. But instead of using this nice language they created this monster, called Objective-C, mixing two really different syntaxes for C compatibility. Why they don&#39;t create a smalltalk compiler, able to create fast executables, instead?</p></div></div><p>
I think that when Stepstone invented Objective-C — which now happens to be primarily used by Apple — they were thinking it would be nice to be able to call the existing standard libraries immediately. In fact, this makes a whole bunch of people very happy; it makes me happy because when I&#39;m programming OpenGL for the iPhone it still looks exactly the same as OpenGL and it makes companies like Adobe happy because all that C/C++ code they&#39;ve built up over the past 20+ years for Photoshop can continue to be used.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Tue, 12 May 2009 16:13:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Isn&#39;t Objective C the same as C++, only done differently? As in, extend C to natively support an OOP paradigm?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Tue, 12 May 2009 16:44:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Objective C is C with the Smalltalk message passing model thrown in.</p><p>I&#39;ve been doing a little of Objective C lately because our boss wants to make apps for the iPhone. Guess what? on the iPhone, Objective C does not have garbage collection! all you can do is manually increment and decrement references. And it has all sorts of crazy rules, like not throwing an exception in constructors, &#39;alloc&#39; setting the ref count of an object to 1, etc.</p><p>C++ is much better in memory management in this regard. RAII is a huge huge win in productivity.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Tue, 12 May 2009 17:12:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Nope, same objective and superficially similar, but the runtime is very different (mostly because Objective-C is fully reflective) and the usage patterns related to the libraries that usually go with each language (ie, STL versus the NextStep stuff) are very different.</p><p>For example, in Objective-C you can do this:
</p><div class="source-code snippet"><div class="inner"><pre>   NSString <span class="k3">*</span>name <span class="k3">=</span> <span class="k3">&lt;</span>string from somewhere&gt;<span class="k2">;</span>
   <span class="k2">[</span>self performSelector:@selector<span class="k2">(</span>name<span class="k2">)</span><span class="k2">]</span><span class="k2">;</span>
</pre></div></div><p>

Or indeed:
</p><div class="source-code snippet"><div class="inner"><pre>   NSArray <span class="k3">*</span>arrayOfObjects<span class="k2">;</span>

   <span class="c">// fill arrayOfObjects somehow</span>

   <span class="k2">[</span>arrayOfObjects performSelector:@selector<span class="k2">(</span>name<span class="k2">)</span><span class="k2">]</span><span class="k2">;</span> <span class="c">// all objects in the array get a chance to perform the selector</span>
</pre></div></div><p>

Furthermore, the result of this:
</p><div class="source-code snippet"><div class="inner"><pre>   NSObject <span class="k3">*</span>object <span class="k3">=</span> nil<span class="k2">;</span> <span class="c">//or NULL, they're interchangable</span>
   <span class="k2">[</span>object doWhatever<span class="k2">]</span><span class="k2">;</span>
</pre></div></div><p>

Is fully defined (it&#39;ll do nothing and return nil) even though the object you&#39;re calling the method on is set to nil and that type of object doesn&#39;t explicitly declare that it responds to doWhatever. You&#39;ll get a compiler warning because of the latter, but not an error.</p><p>The former means you can chain a bunch of functions at runtime and care only about the end result, e.g.
</p><div class="source-code snippet"><div class="inner"><pre>   Texture2D <span class="k3">*</span>texture <span class="k3">=</span> <span class="k2">[</span><span class="k2">[</span><span class="k2">[</span>object property1<span class="k2">]</span> property2<span class="k2">]</span> property3<span class="k2">]</span><span class="k2">;</span>
</pre></div></div><p>

Assuming property1, property2 and property3 are getters for classes, you don&#39;t need to test whether any of them returns nil. That&#39;s the equivalent of calling three functions and setting texture to nil if you encounter a nil anywhere along the way.</p><p>The latter is because the program is linked at runtime, not at compile time, so there&#39;s no need to generate an error. In addition, an object may implement methods it doesn&#39;t publicly declare or may want to catch any requests for it to run methods that it doesn&#39;t have. Or, in the above example, you may have a bunch of objects in an NSArray of completely different types, some of which respond to a selector, some of which don&#39;t, so the runtime needs to be able to gracefully handle attempts to call non-existent methods.</p><p>I think a lot of this stuff is what the proprietary QT precompiler achieves to massage QT onto C++. For all I know, C++ people can do broadly similar things with BOOST or something if they&#39;re willing to write all their code in the correct way, but I&#39;ll wager that if so it&#39;s more fiddlesome and much more recent than Objective-C&#39;s 1986 launch.</p><p>My understanding is also that the dynamic binding stuff is why OS X and NextStep don&#39;t have anything like the scale of issues maintaining ABIs that Win32 does. Though it&#39;s probably also because Apple are more able and therefore more willing to go through major technology upheavals and as a side effect dump all their old stuff, what with being able to control the hardware and the software.</p><p>Also, as of Version 2.0 (which is very recent), the Objective-C runtime also has optional garbage collection. But I&#39;ve not looked into it, so I&#39;ve no real idea about that. It certainly works so that you can write reference counting code, compile it with garbage collection on and have all the usual reference counting stuff compile to NOPs, allowing you to use the same code in garbage collected projects and non-garbage collected projects or to repurpose existing code into a garbage collected project without modifying it. But that&#39;s pretty much everything I know.</p><p>EDIT:
</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811277#target">axilmar</a> said:</div><div class="quote"><p>Guess what? on the iPhone, Objective C does not have garbage collection! all you can do is manually increment and decrement references. And it has all sorts of crazy rules, like not throwing an exception in constructors, &#39;alloc&#39; setting the ref count of an object to 1, etc.</p></div></div><p>
A lot of Objective-C is informal usage norms. To allocate a new object that takes no arguments, you could do either:
</p><div class="source-code snippet"><div class="inner"><pre>   Object <span class="k3">*</span>NewObject <span class="k3">=</span> <span class="k2">[</span><span class="k2">[</span>Object alloc<span class="k2">]</span> init<span class="k2">]</span><span class="k2">;</span>
</pre></div></div><p>
Or:
</p><div class="source-code snippet"><div class="inner"><pre>   Object <span class="k3">*</span>NewObject <span class="k3">=</span> <span class="k2">[</span>Object <span class="k1">new</span><span class="k2">]</span><span class="k2">;</span> <span class="c">// calls alloc and init</span>
</pre></div></div><p>
Since in Objective-C, all classes are their own class factories; you call a class method (ie, the same as a C++ static method) to allocate all new instances of a class. Subsequently, you can declare that you want to hang onto an object (ie, increment its reference count) using:
</p><div class="source-code snippet"><div class="inner"><pre>   <span class="k2">[</span>NewObject retain<span class="k2">]</span><span class="k2">;</span>
</pre></div></div><p>
Or declare that you&#39;re done with an object (ie, decrease its reference count and cause it to deallocate itself if the count goes to zero) with:
</p><div class="source-code snippet"><div class="inner"><pre>   <span class="k2">[</span>NewObject release<span class="k2">]</span><span class="k2">;</span>
</pre></div></div><p>
All objects are ultimately derived from NSObject, so in your init code you&#39;d put:
</p><div class="source-code snippet"><div class="inner"><pre>   <span class="k2">[</span>super init<span class="k2">]</span><span class="k2">;</span> <span class="c">// calls init in whatever you inherited from</span>
</pre></div></div><p>
Then, in your dealloc:
</p><div class="source-code snippet"><div class="inner"><pre>   <span class="k2">[</span>super dealloc<span class="k2">]</span><span class="k2">;</span>
</pre></div></div><p>
There&#39;s also an autorelease pool, which you can assign objects to as the equivalent of doing a retain with no intention to subsequently do a release so that their memory does not eventually leak.</p><p>I guess you&#39;re technically incrementing and decrementing a reference count somewhere, but it&#39;s not as low level as axilmar makes it sound.</p><p>EDIT2:<br />Oh, alloc &amp; initing does an implicit retain, if you see what I mean. So if you created an object and used it briefly you might have:
</p><div class="source-code snippet"><div class="inner"><pre>   MyObject <span class="k3">*</span>obj <span class="k3">=</span> <span class="k2">[</span>MyObject <span class="k1">new</span><span class="k2">]</span><span class="k2">;</span>
   <span class="k2">[</span>obj doThing1<span class="k2">]</span><span class="k2">;</span>
   <span class="k2">[</span>otherobj doFunctionWith:obj<span class="k2">]</span><span class="k2">;</span>
   <span class="k2">[</span>obj release<span class="k2">]</span><span class="k2">;</span>
</pre></div></div><p>
So you can use it at the C/C++ level if you want. The difference is that supposing doFunctionWith: had decided to keep &#39;obj&#39; for later, it could have called retain and kept a pointer to the thing. As a result, it won&#39;t be deallocated when you call release and it&#39;ll be up to otherobj to free it when it is done.</p><p>Obviously you need to be careful about when you decide to take a copy of something and when you simply retain it, depending on whether you&#39;re expecting other parts of the program to mutate the value.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Tue, 12 May 2009 17:34:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811287#target">Thomas Harte</a> said:</div><div class="quote"><p>
Oh, alloc &amp; initing does an implicit retain, if you see what I mean. So if you created an object and used it briefly you might have: 
</p></div></div><p>

That why I said that the ref count is initially 1 when alloc returns.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
So you can use it at the C/C++ level if you want.
</p></div></div><p>

I prefer C++ which does a &#39;release&#39; automatically via shared ptrs.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Tue, 12 May 2009 18:51:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811308#target">axilmar</a> said:</div><div class="quote"><p>That why I said that the ref count is initially 1 when alloc returns.</p></div></div><p>
I wasn&#39;t correcting you, I was expanding on what you said since I believed that at least some pure-C/C++ people would take the manual reference count changes to mean really really low level stuff. Since you&#39;ve professionally researched the topic, I&#39;d be surprised if you didn&#39;t have a thorough understanding.
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>I prefer C++ which does a &#39;release&#39; automatically via shared ptrs.</p></div></div><p>
I don&#39;t know shared ptrs, presumably they do something like overload the assignment operator and fix things up otherwise in their constructor and destructor?</p><p>There&#39;s another difference between Objective-C and C++ — you can&#39;t overload operators in Objective-C. And the &#39;standard libraries&#39; (which I&#39;m still taking to be the NextStep-derived stuff, including GNUStep, based on real-world usage of the language) are just generally extremely verbose.</p><p>I think my feeling about the pre-2.0 Objective-C memory handling is that it&#39;s better than C but still clearly performance oriented from the age when the 68000 was the predominant target for progressive computing. And the iPhone is just all-over weird with memory management, both the absence of garbage collection after it took so long for Apple to work it into a system that plays nicely with their desktop OS libraries and the weirdo virtual memory arrangements.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Tue, 12 May 2009 20:17:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I do a lot of c++ and I&#39;m really starting to look for alternatives. Generally i don&#39;t make &quot;coding mistakes&quot;.. but it&#39;s really painful hunting down logic and other mistakes in c++. First of all, there is a lot of boiler plate code hiding what is going on for quick reading. Secondly, there are enough things to keep track of in the small function case yet alone for the big connected one.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Goalie Ca)</author>
		<pubDate>Tue, 12 May 2009 22:07:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811339#target">Goalie Ca</a> said:</div><div class="quote"><p>
I do a lot of c++ and I&#39;m really starting to look for alternatives. Generally i don&#39;t make &quot;coding mistakes&quot;.. but it&#39;s really painful hunting down logic and other mistakes in c++. First of all, there is a lot of boiler plate code hiding what is going on for quick reading. Secondly, there are enough things to keep track of in the small function case yet alone for the big connected one. 
</p></div></div><p>

Very true. </p><p>I have to type almost twice the code in C++ than in Java to achieve the same thing (except when I use Swing - then I have to type more code than Qt, but that&#39;s just the API).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Tue, 12 May 2009 23:40:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811353#target">axilmar</a> said:</div><div class="quote"><p>
I have to type almost twice the code in C++ than in Java to achieve the same thing (except when I use Swing - then I have to type more code than Qt, but that&#39;s just the API). 
</p></div></div><p>
Why don&#39;t you like D then? D seems to have nicer syntax, and can be more terse. You seem to be alternating between not liking small implementation details of C++, and not liking the imperative paradigm altogether. Is it something like &quot;I&#39;d prefer not to have C++, but if I am stuck with it, I&#39;d prefer it to have nicer syntax&quot;, in which case I fail to see how D does not solve your issue.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Tue, 12 May 2009 23:59:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811358#target">SiegeLord</a> said:</div><div class="quote"><p>
Why don&#39;t you like D then? D seems to have nicer syntax, and can be more terse. You seem to be alternating between not liking small implementation details of C++, and not liking the imperative paradigm altogether. Is it something like &quot;I&#39;d prefer not to have C++, but if I am stuck with it, I&#39;d prefer it to have nicer syntax&quot;, in which case I fail to see how D does not solve your issue. 
</p></div></div><p>

1) Our customer will not accept D.</p><p>2) there are some issues with it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Wed, 13 May 2009 01:22:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/600179/811256#target">Tobias Dammers</a> said:</div><div class="quote"><p>Curly-bracket languages (the &quot;C-ish&quot; ones) dominate the scene for one simple reason: They are similar enough to make the transition between them ridiculously easy.</p></div></div><p>

I can follow this argumentation. I benefit from it, too. There is always a fight between standardization and innovation. Standardization is important. But if you standardize too much you kill the innovation.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Martin Kalbfuß)</author>
		<pubDate>Wed, 13 May 2009 01:28:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Any innovation in one language is adopted quickly by the other similar languages, becoming a standard? <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anonymous)</author>
		<pubDate>Wed, 13 May 2009 02:28:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Per <a href="http://www.allegro.cc/forums/thread/600255/811650#target">this</a> post from another thread, I wonder if there are any revisions to the exception specification implementation in C++0x. Anybody know? They sound like a really good thing, but as the links point out, they end up being more of a burden or curse in current implementations.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Fri, 15 May 2009 08:07:23 +0000</pubDate>
	</item>
</rss>
