<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments for Sutter’s Mill</title>
	<atom:link href="http://herbsutter.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://herbsutter.com</link>
	<description>Herb Sutter on software, hardware, and concurrency</description>
	<lastBuildDate>Thu, 09 Feb 2012 09:09:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>Comment on Going Native Sessions Online by Yannick</title>
		<link>http://herbsutter.com/2012/02/08/going-native-sessions-online/#comment-4790</link>
		<dc:creator><![CDATA[Yannick]]></dc:creator>
		<pubDate>Thu, 09 Feb 2012 09:09:00 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1383#comment-4790</guid>
		<description><![CDATA[This was very interesting and stimulating indeed !

It really looked like a JEDI masters council, with the padawans in the room and online :o)
With Bjarne as Yoda, of course !

Thank you !]]></description>
		<content:encoded><![CDATA[<p>This was very interesting and stimulating indeed !</p>
<p>It really looked like a JEDI masters council, with the padawans in the room and online :o)<br />
With Bjarne as Yoda, of course !</p>
<p>Thank you !</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Going Native Sessions Online by A Going Native (C++) konferencia összes előadása online nézhető &#124; szimpatikus.hu trackback proxy</title>
		<link>http://herbsutter.com/2012/02/08/going-native-sessions-online/#comment-4788</link>
		<dc:creator><![CDATA[A Going Native (C++) konferencia összes előadása online nézhető &#124; szimpatikus.hu trackback proxy]]></dc:creator>
		<pubDate>Thu, 09 Feb 2012 08:21:37 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1383#comment-4788</guid>
		<description><![CDATA[[...] Szimpatikus.hu Közösség, a &#8220;A Going Native (C++) konferencia összes előadása online nézhető&#8221; című bejegyzésre szeretném felhívni a figyelmeteket. Várom a hozzászólásokat, [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Szimpatikus.hu Közösség, a &#8220;A Going Native (C++) konferencia összes előadása online nézhető&#8221; című bejegyzésre szeretném felhívni a figyelmeteket. Várom a hozzászólásokat, [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Going Native Sessions Online by Andrzej Krzemieński</title>
		<link>http://herbsutter.com/2012/02/08/going-native-sessions-online/#comment-4787</link>
		<dc:creator><![CDATA[Andrzej Krzemieński]]></dc:creator>
		<pubDate>Thu, 09 Feb 2012 08:16:44 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1383#comment-4787</guid>
		<description><![CDATA[And thanks to the organizers! It was very educating and inspiring.]]></description>
		<content:encoded><![CDATA[<p>And thanks to the organizers! It was very educating and inspiring.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Day 2 Tomorrow (Friday) by Alfonse</title>
		<link>http://herbsutter.com/2012/02/02/goingnative-2012-day-2-tomorrow-friday/#comment-4786</link>
		<dc:creator><![CDATA[Alfonse]]></dc:creator>
		<pubDate>Thu, 09 Feb 2012 05:03:07 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1375#comment-4786</guid>
		<description><![CDATA[&gt; But even simpler things like array_ref/data_ref/str_ref, shared_array, a range interface for all algorithms are even more important.

The range stuff I can understand. But I have no idea what &quot;array_ref&quot; and such are for.

Furthermore, when it comes to &quot;getting something done&quot;, range-based algorithms aren&#039;t something I see as an impediment to my work. They&#039;re a nicety, some good quality-of-life stuff, but nothing more than that.

If the argument is that people want to use other languages because they have a larger, more feature-rich standard library, they&#039;re *not* talking about range stuff or shared_arrays. Those are minor trivialities compared to networking and such.]]></description>
		<content:encoded><![CDATA[<p>&gt; But even simpler things like array_ref/data_ref/str_ref, shared_array, a range interface for all algorithms are even more important.</p>
<p>The range stuff I can understand. But I have no idea what &#8220;array_ref&#8221; and such are for.</p>
<p>Furthermore, when it comes to &#8220;getting something done&#8221;, range-based algorithms aren&#8217;t something I see as an impediment to my work. They&#8217;re a nicety, some good quality-of-life stuff, but nothing more than that.</p>
<p>If the argument is that people want to use other languages because they have a larger, more feature-rich standard library, they&#8217;re *not* talking about range stuff or shared_arrays. Those are minor trivialities compared to networking and such.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Day 2 Tomorrow (Friday) by Olaf van der Spek</title>
		<link>http://herbsutter.com/2012/02/02/goingnative-2012-day-2-tomorrow-friday/#comment-4784</link>
		<dc:creator><![CDATA[Olaf van der Spek]]></dc:creator>
		<pubDate>Wed, 08 Feb 2012 23:03:05 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1375#comment-4784</guid>
		<description><![CDATA[&gt; This stops being possible when C++ has a gigantic standard library. 

Isn&#039;t a large part of the standard library just portable C++? 

&gt; Porting for example, Python to another platform is an arduous task.

Is it? I&#039;d expect most of it to be written in a portable language.

I do find it kinda strange that Herb seems to focus on higher level libs. IMO lower level libs are more important to get standardized first. Standard binary (a)sync file/network IO for example would be great.
Having standard compression and crypto would be welcome too.
But even simpler things like array_ref/data_ref/str_ref, shared_array, a range interface for all algorithms are even more important.
You can&#039;t do high level stuff without getting the low level stuff right first.]]></description>
		<content:encoded><![CDATA[<p>&gt; This stops being possible when C++ has a gigantic standard library. </p>
<p>Isn&#8217;t a large part of the standard library just portable C++? </p>
<p>&gt; Porting for example, Python to another platform is an arduous task.</p>
<p>Is it? I&#8217;d expect most of it to be written in a portable language.</p>
<p>I do find it kinda strange that Herb seems to focus on higher level libs. IMO lower level libs are more important to get standardized first. Standard binary (a)sync file/network IO for example would be great.<br />
Having standard compression and crypto would be welcome too.<br />
But even simpler things like array_ref/data_ref/str_ref, shared_array, a range interface for all algorithms are even more important.<br />
You can&#8217;t do high level stuff without getting the low level stuff right first.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Day 2 Tomorrow (Friday) by Alfonse</title>
		<link>http://herbsutter.com/2012/02/02/goingnative-2012-day-2-tomorrow-friday/#comment-4783</link>
		<dc:creator><![CDATA[Alfonse]]></dc:creator>
		<pubDate>Wed, 08 Feb 2012 16:51:47 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1375#comment-4783</guid>
		<description><![CDATA[Going Native was absolutely excellent from all involved.

I did have one question. In your Day 2 keynote, you really pushed hard for a much, *much* larger standard library. And I find this disconcerting, for one very important reason.

The first language ported to *any* platform is C. No question about that. The reason being? It&#039;s vital to compiling the OS, but also because it&#039;s tiny. C compilers are small and simple; they can easily be bootstrapped. The C-standard library is similarly microscopic.

What is the second language ported to any platform? C++. Why? For similar reasons to C. Important software is written using it. But also, its standard library is fairly small. You don&#039;t have to port much more than some basic file IO. `std::vector` is pretty cross-platform. You need to port `std::streambuf`, and a few OS and locale-related functions. But that&#039;s it.

This stops being possible when C++ has a gigantic standard library. Porting for example, Python to another platform is an arduous task.

The reason languages like C#, Java, and Python can have immense standard libraries is that there is only *one* implementation of them. OK, there are a couple of Java implementations, and .NET has one in the form of Mono. But these are generally also-rans as far as implementations go. There is one .NET implementation: Microsoft&#039;s. That&#039;s the standard. There is one Java implementation: Sun/Oracle&#039;s. That&#039;s the standard. There is one Python implementation.

C++ has 3 major implementations: GCC+libstdc++, Visual Studio, and Clang&amp;libc++, as well as a plethora of minor ones (ICC, etc). You are asking all of these developers to implement some pretty heavyweight code. XML parsers (that&#039;s pretty substantial for real XML, which means XML IDs, DTDs, XInclude, etc), JSON parsers, sockets, and other stuff. That&#039;s a *lot* of work. And that means a **lot** of bugs.

To make this even remotely feasible, you would need the various C++ interests to create an open-source repository for most of these libraries so that they can share implementations. At which point... all you have is Boost that just happens to be shipped with your compiler.

I just don&#039;t see this as a good idea.

Plus, there&#039;s the very real possibility of the standards committee screwing them up. Take an XML parser. Is that going to be properly C++ized, so that it meshes well with standard algorithms? Will it&#039;s DOM-style interface be an iterator-compatible interface? How does that affect parsing performance? Will the parser be able to be in-situ like RapidXML for that added bit of performance, or will it have to do something else? What parts of XML will it include? Will XSD be included as well (I hope not, because that makes it much more complex)? Will it offer several different styles of parser (reader/writer, SAX-style push parser, and DOM-style tree), or will it just force one on you? How do you deal with Unicode in XML? Does the parser provide a small set of Unicode encodings that it supports, and if you don&#039;t use them, you&#039;re out of luck? Or is it extensible in some way? What&#039;s the interface for extending it, and does it differ between the three parser styles?

The thing about XML parsing today is that you can pick up what you want off the shelf. If I need serious XML processing, I go to LibXML2. It is a full, proper XML parser that has many styles of parsing files. It 

C#, Java, and Python were all defined by *fiat*. For better or worse, their APIs were developed by one tiny group/person, who said, &quot;Our API will look like this!&quot; The committee could easily get bogged down in minutiae over these libraries.

And if they don&#039;t, if the committee basically just rubber-stamps proposals, then we could very easily get a big problem: one thing in the standard doesn&#039;t really work well with other things in the same standard. One of the points of a standard is interoperability: all the pieces work together. With C++, this is mostly true, but there are... odd places. `iostream` really looks out of place next to the STL-derived containers and algorithms. A bit of glue was added with the streambuf iterators, but then... do we really need the iostreams if we can just create a streambuf and input/output iterate over them with algorithms?

Big libraries are not something that committee-based standards are really capable of doing. C# may be an ECMA standard, but that&#039;s because Microsoft did most of the work internally and just said, &quot;Hey, review this and make sure it&#039;s not stupid.&quot; If we&#039;re going to have dozens of contributors for library components running in and dropping code, basically saying, &quot;standardize this pretty much as is,&quot; that&#039;s going to be a real problem.

I get the problem, I really do. Standard libraries are the first stop for people looking for a way to solve problems. And XML, JSON, etc, are problems that a lot of applications need solving. But I don&#039;t think direct standardization is the way to go for these things. It could very easily do more harm in the long-run, creating buggy standard libraries with esoteric, poorly-constructed interfaces that nobody uses anyway.

Personally, I&#039;ve always felt that C++, like C, should have standard libraries that are very general. They should provide common utilities that could be used in pretty much any program. They shouldn&#039;t be providing specific functionality that would be called for directly by design.]]></description>
		<content:encoded><![CDATA[<p>Going Native was absolutely excellent from all involved.</p>
<p>I did have one question. In your Day 2 keynote, you really pushed hard for a much, *much* larger standard library. And I find this disconcerting, for one very important reason.</p>
<p>The first language ported to *any* platform is C. No question about that. The reason being? It&#8217;s vital to compiling the OS, but also because it&#8217;s tiny. C compilers are small and simple; they can easily be bootstrapped. The C-standard library is similarly microscopic.</p>
<p>What is the second language ported to any platform? C++. Why? For similar reasons to C. Important software is written using it. But also, its standard library is fairly small. You don&#8217;t have to port much more than some basic file IO. `std::vector` is pretty cross-platform. You need to port `std::streambuf`, and a few OS and locale-related functions. But that&#8217;s it.</p>
<p>This stops being possible when C++ has a gigantic standard library. Porting for example, Python to another platform is an arduous task.</p>
<p>The reason languages like C#, Java, and Python can have immense standard libraries is that there is only *one* implementation of them. OK, there are a couple of Java implementations, and .NET has one in the form of Mono. But these are generally also-rans as far as implementations go. There is one .NET implementation: Microsoft&#8217;s. That&#8217;s the standard. There is one Java implementation: Sun/Oracle&#8217;s. That&#8217;s the standard. There is one Python implementation.</p>
<p>C++ has 3 major implementations: GCC+libstdc++, Visual Studio, and Clang&amp;libc++, as well as a plethora of minor ones (ICC, etc). You are asking all of these developers to implement some pretty heavyweight code. XML parsers (that&#8217;s pretty substantial for real XML, which means XML IDs, DTDs, XInclude, etc), JSON parsers, sockets, and other stuff. That&#8217;s a *lot* of work. And that means a **lot** of bugs.</p>
<p>To make this even remotely feasible, you would need the various C++ interests to create an open-source repository for most of these libraries so that they can share implementations. At which point&#8230; all you have is Boost that just happens to be shipped with your compiler.</p>
<p>I just don&#8217;t see this as a good idea.</p>
<p>Plus, there&#8217;s the very real possibility of the standards committee screwing them up. Take an XML parser. Is that going to be properly C++ized, so that it meshes well with standard algorithms? Will it&#8217;s DOM-style interface be an iterator-compatible interface? How does that affect parsing performance? Will the parser be able to be in-situ like RapidXML for that added bit of performance, or will it have to do something else? What parts of XML will it include? Will XSD be included as well (I hope not, because that makes it much more complex)? Will it offer several different styles of parser (reader/writer, SAX-style push parser, and DOM-style tree), or will it just force one on you? How do you deal with Unicode in XML? Does the parser provide a small set of Unicode encodings that it supports, and if you don&#8217;t use them, you&#8217;re out of luck? Or is it extensible in some way? What&#8217;s the interface for extending it, and does it differ between the three parser styles?</p>
<p>The thing about XML parsing today is that you can pick up what you want off the shelf. If I need serious XML processing, I go to LibXML2. It is a full, proper XML parser that has many styles of parsing files. It </p>
<p>C#, Java, and Python were all defined by *fiat*. For better or worse, their APIs were developed by one tiny group/person, who said, &#8220;Our API will look like this!&#8221; The committee could easily get bogged down in minutiae over these libraries.</p>
<p>And if they don&#8217;t, if the committee basically just rubber-stamps proposals, then we could very easily get a big problem: one thing in the standard doesn&#8217;t really work well with other things in the same standard. One of the points of a standard is interoperability: all the pieces work together. With C++, this is mostly true, but there are&#8230; odd places. `iostream` really looks out of place next to the STL-derived containers and algorithms. A bit of glue was added with the streambuf iterators, but then&#8230; do we really need the iostreams if we can just create a streambuf and input/output iterate over them with algorithms?</p>
<p>Big libraries are not something that committee-based standards are really capable of doing. C# may be an ECMA standard, but that&#8217;s because Microsoft did most of the work internally and just said, &#8220;Hey, review this and make sure it&#8217;s not stupid.&#8221; If we&#8217;re going to have dozens of contributors for library components running in and dropping code, basically saying, &#8220;standardize this pretty much as is,&#8221; that&#8217;s going to be a real problem.</p>
<p>I get the problem, I really do. Standard libraries are the first stop for people looking for a way to solve problems. And XML, JSON, etc, are problems that a lot of applications need solving. But I don&#8217;t think direct standardization is the way to go for these things. It could very easily do more harm in the long-run, creating buggy standard libraries with esoteric, poorly-constructed interfaces that nobody uses anyway.</p>
<p>Personally, I&#8217;ve always felt that C++, like C, should have standard libraries that are very general. They should provide common utilities that could be used in pretty much any program. They shouldn&#8217;t be providing specific functionality that would be called for directly by design.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #103: Smart Pointers, Part 1 (Difficulty: 3/10) by Hal Pratt</title>
		<link>http://herbsutter.com/2012/01/20/gotw-103-smart-pointers-part-1-difficulty-310/#comment-4782</link>
		<dc:creator><![CDATA[Hal Pratt]]></dc:creator>
		<pubDate>Wed, 08 Feb 2012 09:31:25 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1346#comment-4782</guid>
		<description><![CDATA[The solution to Waldemar&#039;s first problem is to use allocate_shared &amp; make the allocator a friend, or, anyway, it will be once LWG open issue #2070 is resolved (http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#2070). In the meantime, I suppose you can just peek inside your vendor&#039;s allocate_shared implementation to see who to friend.]]></description>
		<content:encoded><![CDATA[<p>The solution to Waldemar&#8217;s first problem is to use allocate_shared &amp; make the allocator a friend, or, anyway, it will be once LWG open issue #2070 is resolved (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#2070" rel="nofollow">http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#2070</a>). In the meantime, I suppose you can just peek inside your vendor&#8217;s allocate_shared implementation to see who to friend.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #103: Smart Pointers, Part 1 (Difficulty: 3/10) by Sebastian Mach (phresnel)</title>
		<link>http://herbsutter.com/2012/01/20/gotw-103-smart-pointers-part-1-difficulty-310/#comment-4780</link>
		<dc:creator><![CDATA[Sebastian Mach (phresnel)]]></dc:creator>
		<pubDate>Tue, 07 Feb 2012 16:21:11 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1346#comment-4780</guid>
		<description><![CDATA[(Xeo gave the purist auto_ptr answer. So here my purist answer on shared_ptr vs. unique_ptr)

Use shared_ptr to allow for multiple isochronal owners, none of which shall have exclusive right to delete.

Use unique_ptr to allow for exactly one isochronal owner.]]></description>
		<content:encoded><![CDATA[<p>(Xeo gave the purist auto_ptr answer. So here my purist answer on shared_ptr vs. unique_ptr)</p>
<p>Use shared_ptr to allow for multiple isochronal owners, none of which shall have exclusive right to delete.</p>
<p>Use unique_ptr to allow for exactly one isochronal owner.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Minus 3 Days by Herb Sutter</title>
		<link>http://herbsutter.com/2012/01/30/goingnative-2012-minus-3-days/#comment-4779</link>
		<dc:creator><![CDATA[Herb Sutter]]></dc:creator>
		<pubDate>Mon, 06 Feb 2012 04:58:36 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1357#comment-4779</guid>
		<description><![CDATA[Live streaming is different from playing videos on demand. The latter works on all popular platforms -- check it out now, three of the videos are posted so far, starting with Bjarne&#039;s opening keynote. Works fine on iPhone/iPad...]]></description>
		<content:encoded><![CDATA[<p>Live streaming is different from playing videos on demand. The latter works on all popular platforms &#8212; check it out now, three of the videos are posted so far, starting with Bjarne&#8217;s opening keynote. Works fine on iPhone/iPad&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Minus 3 Days by bohan</title>
		<link>http://herbsutter.com/2012/01/30/goingnative-2012-minus-3-days/#comment-4778</link>
		<dc:creator><![CDATA[bohan]]></dc:creator>
		<pubDate>Sun, 05 Feb 2012 22:20:16 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1357#comment-4778</guid>
		<description><![CDATA[I&#039;m also disappointed that people with a modern w3c-compliant browser, and a multitude of video codecs are unable to watch the videos. I&#039;m sorry to say this, but I really don&#039;t buy &quot;technical limitation&quot; as an excuse, and believe It&#039;s a deliberate choice made by the organisers to exclude people that don&#039;t belong in their realm. To defend my point of view, I have a simple fact: I never encounter any problem watching videos, with any site.. but Microsoft&#039;s! Can you spot where the problem is?]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m also disappointed that people with a modern w3c-compliant browser, and a multitude of video codecs are unable to watch the videos. I&#8217;m sorry to say this, but I really don&#8217;t buy &#8220;technical limitation&#8221; as an excuse, and believe It&#8217;s a deliberate choice made by the organisers to exclude people that don&#8217;t belong in their realm. To defend my point of view, I have a simple fact: I never encounter any problem watching videos, with any site.. but Microsoft&#8217;s! Can you spot where the problem is?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Minus 1 Day by Marc Mutz</title>
		<link>http://herbsutter.com/2012/02/01/goingnative-2012-minus-1-day/#comment-4772</link>
		<dc:creator><![CDATA[Marc Mutz]]></dc:creator>
		<pubDate>Thu, 02 Feb 2012 12:48:02 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1368#comment-4772</guid>
		<description><![CDATA[If you&#039;re in Berlin, Germany, consider joining us at the KDAB offices:
http://marcmutz.wordpress.com/2012/01/31/goingnative12-kdab-berlin/]]></description>
		<content:encoded><![CDATA[<p>If you&#8217;re in Berlin, Germany, consider joining us at the KDAB offices:<br />
<a href="http://marcmutz.wordpress.com/2012/01/31/goingnative12-kdab-berlin/" rel="nofollow">http://marcmutz.wordpress.com/2012/01/31/goingnative12-kdab-berlin/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Minus 1 Day by GoingNative 2012: Minus 1 Day « Sutter’s Mill &#171; SFML Coder</title>
		<link>http://herbsutter.com/2012/02/01/goingnative-2012-minus-1-day/#comment-4769</link>
		<dc:creator><![CDATA[GoingNative 2012: Minus 1 Day « Sutter’s Mill &#171; SFML Coder]]></dc:creator>
		<pubDate>Wed, 01 Feb 2012 19:20:10 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1368#comment-4769</guid>
		<description><![CDATA[[...] GoingNative 2012: Minus 1 Day « Sutter’s Mill. Rate this:  Share this:FacebookTwitterEmailPrintRedditDiggLike this:LikeBe the first to like this post.    Categories: Uncategorized Tags: C++, c++11, going, goingnative, Microsoft, native, Programming       Comments (0) Trackbacks (0) Leave a comment Trackback [...]]]></description>
		<content:encoded><![CDATA[<p>[...] GoingNative 2012: Minus 1 Day « Sutter’s Mill. Rate this:  Share this:FacebookTwitterEmailPrintRedditDiggLike this:LikeBe the first to like this post.    Categories: Uncategorized Tags: C++, c++11, going, goingnative, Microsoft, native, Programming       Comments (0) Trackbacks (0) Leave a comment Trackback [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Minus 3 Days by slartie</title>
		<link>http://herbsutter.com/2012/01/30/goingnative-2012-minus-3-days/#comment-4767</link>
		<dc:creator><![CDATA[slartie]]></dc:creator>
		<pubDate>Wed, 01 Feb 2012 09:41:31 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1357#comment-4767</guid>
		<description><![CDATA[I wish I could attend, but alas Redmond is a heck of a trek away from Denmark, and apparently the airlines demand money for you to sit and stare out the window for 12 hours.

I&#039;ll be glued to the stream as much as possible, and VoD the rest. Herb, thanks go to you and all the C++ guys at MS who keep waving the &quot;C++ is more relevant than ever&quot;-flag. Much appreciated!]]></description>
		<content:encoded><![CDATA[<p>I wish I could attend, but alas Redmond is a heck of a trek away from Denmark, and apparently the airlines demand money for you to sit and stare out the window for 12 hours.</p>
<p>I&#8217;ll be glued to the stream as much as possible, and VoD the rest. Herb, thanks go to you and all the C++ guys at MS who keep waving the &#8220;C++ is more relevant than ever&#8221;-flag. Much appreciated!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Minus 3 Days by Charles</title>
		<link>http://herbsutter.com/2012/01/30/goingnative-2012-minus-3-days/#comment-4766</link>
		<dc:creator><![CDATA[Charles]]></dc:creator>
		<pubDate>Wed, 01 Feb 2012 01:11:48 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1357#comment-4766</guid>
		<description><![CDATA[I haven&#039;t been following the Moonlight project, but I suspect it&#039;s not dead. That said, the Silverlight browser plug-in works on Windows and OSX for sure. So, it&#039;s _not_ Windows-only. Mac users (not iOS) will be able to easily install the SL plug-in and watch live. 

Not sure what to say about any and all versions of Linux. Try Moonlight out. &quot;Should&quot; work. 

We have an SL dependency because:

1) We want to Smooth Stream the media (very effective approach) and our media partner employs IIS7 SS
2) Smooth streaming technology does not exist for HTML5 video...
3) Flash is not an option...

Charles]]></description>
		<content:encoded><![CDATA[<p>I haven&#8217;t been following the Moonlight project, but I suspect it&#8217;s not dead. That said, the Silverlight browser plug-in works on Windows and OSX for sure. So, it&#8217;s _not_ Windows-only. Mac users (not iOS) will be able to easily install the SL plug-in and watch live. </p>
<p>Not sure what to say about any and all versions of Linux. Try Moonlight out. &#8220;Should&#8221; work. </p>
<p>We have an SL dependency because:</p>
<p>1) We want to Smooth Stream the media (very effective approach) and our media partner employs IIS7 SS<br />
2) Smooth streaming technology does not exist for HTML5 video&#8230;<br />
3) Flash is not an option&#8230;</p>
<p>Charles</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Minus 5 Days by Valentin Rusu &#187; Qui a dit que C++ était pour les anciens ?</title>
		<link>http://herbsutter.com/2012/01/28/goingnative-2012-minus-5-days/#comment-4764</link>
		<dc:creator><![CDATA[Valentin Rusu &#187; Qui a dit que C++ était pour les anciens ?]]></dc:creator>
		<pubDate>Tue, 31 Jan 2012 20:27:43 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1354#comment-4764</guid>
		<description><![CDATA[[...] aura lieu la convention global C++ - voir ce lien, par exemple. Sur ce billet, nous aurons la surprise de voir que la moitié des inscrits ont moins [...]]]></description>
		<content:encoded><![CDATA[<p>[...] aura lieu la convention global C++ &#8211; voir ce lien, par exemple. Sur ce billet, nous aurons la surprise de voir que la moitié des inscrits ont moins [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Minus 3 Days by Herb Sutter</title>
		<link>http://herbsutter.com/2012/01/30/goingnative-2012-minus-3-days/#comment-4759</link>
		<dc:creator><![CDATA[Herb Sutter]]></dc:creator>
		<pubDate>Mon, 30 Jan 2012 23:56:39 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1357#comment-4759</guid>
		<description><![CDATA[@Peterazp: Sorry, I just wanted to manage expectations about video formats and I guess they meant &quot;browsers on Windows.&quot; :)]]></description>
		<content:encoded><![CDATA[<p>@Peterazp: Sorry, I just wanted to manage expectations about video formats and I guess they meant &#8220;browsers on Windows.&#8221; :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Minus 3 Days by peterazp</title>
		<link>http://herbsutter.com/2012/01/30/goingnative-2012-minus-3-days/#comment-4756</link>
		<dc:creator><![CDATA[peterazp]]></dc:creator>
		<pubDate>Mon, 30 Jan 2012 20:31:43 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1357#comment-4756</guid>
		<description><![CDATA[&quot;Silverlight is supported by all modern desktop browsers&quot; - Really, have you installed it on Gentoo Linux recently? From the Moonlight (open source implementation for non-Microsoft platforms) F.A.Q I can read:

&quot;Which platforms does Moonlight support?

Moonlight should work on any modern 32bit and 64bit Linux distributions under Firefox versions 3.0 through 4.x, as well as Google Chrome, from both stable and dev channels
We make sure that the plug-in available from this site works on the following platforms: SUSE Linux Enterprise Desktop 11, openSUSE 11.x, Ubuntu 9.10, and Fedora 12.
Older distributions will run Moonlight, but may require that you build Moonlight from source code.&quot;


Well, Firefox 3 and 4 are quite old by now, and I&#039;m using Firefox 9. So I guees most &quot;modern desktop browsers&quot; doesn&#039;t support it, since it doesn&#039;t actually support modern browsers. And that is a shame.

I guess I&#039;ll have to watch it on Channel 9 afterwards. I&#039;m still looking forward to this a lot!]]></description>
		<content:encoded><![CDATA[<p>&#8220;Silverlight is supported by all modern desktop browsers&#8221; &#8211; Really, have you installed it on Gentoo Linux recently? From the Moonlight (open source implementation for non-Microsoft platforms) F.A.Q I can read:</p>
<p>&#8220;Which platforms does Moonlight support?</p>
<p>Moonlight should work on any modern 32bit and 64bit Linux distributions under Firefox versions 3.0 through 4.x, as well as Google Chrome, from both stable and dev channels<br />
We make sure that the plug-in available from this site works on the following platforms: SUSE Linux Enterprise Desktop 11, openSUSE 11.x, Ubuntu 9.10, and Fedora 12.<br />
Older distributions will run Moonlight, but may require that you build Moonlight from source code.&#8221;</p>
<p>Well, Firefox 3 and 4 are quite old by now, and I&#8217;m using Firefox 9. So I guees most &#8220;modern desktop browsers&#8221; doesn&#8217;t support it, since it doesn&#8217;t actually support modern browsers. And that is a shame.</p>
<p>I guess I&#8217;ll have to watch it on Channel 9 afterwards. I&#8217;m still looking forward to this a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Minus 5 Days by Arne Mertz</title>
		<link>http://herbsutter.com/2012/01/28/goingnative-2012-minus-5-days/#comment-4754</link>
		<dc:creator><![CDATA[Arne Mertz]]></dc:creator>
		<pubDate>Mon, 30 Jan 2012 14:52:01 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1354#comment-4754</guid>
		<description><![CDATA[@Future:  Like it says on the site: Silverlight required, i.e. you probably could use Moonlight on Linux]]></description>
		<content:encoded><![CDATA[<p>@Future:  Like it says on the site: Silverlight required, i.e. you probably could use Moonlight on Linux</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Minus 5 Days by Future</title>
		<link>http://herbsutter.com/2012/01/28/goingnative-2012-minus-5-days/#comment-4752</link>
		<dc:creator><![CDATA[Future]]></dc:creator>
		<pubDate>Mon, 30 Jan 2012 07:55:21 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1354#comment-4752</guid>
		<description><![CDATA[Can I watch the live stream under Linux or will they use a propitiatory MS format?]]></description>
		<content:encoded><![CDATA[<p>Can I watch the live stream under Linux or will they use a propitiatory MS format?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Minus 5 Days by jagansai</title>
		<link>http://herbsutter.com/2012/01/28/goingnative-2012-minus-5-days/#comment-4744</link>
		<dc:creator><![CDATA[jagansai]]></dc:creator>
		<pubDate>Sun, 29 Jan 2012 04:17:51 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1354#comment-4744</guid>
		<description><![CDATA[Will watch it onliine.]]></description>
		<content:encoded><![CDATA[<p>Will watch it onliine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on C++11 &#8220;GoingNative 2012&#8221;: Speakers and Sessions by Herb Sutter</title>
		<link>http://herbsutter.com/2012/01/16/c11-goingnative-2012-speakers-and-sessions/#comment-4743</link>
		<dc:creator><![CDATA[Herb Sutter]]></dc:creator>
		<pubDate>Sat, 28 Jan 2012 22:03:34 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1322#comment-4743</guid>
		<description><![CDATA[@Nikhil, @Rahul:

To develop Metro style apps, the Windows team&#039;s guidance is that they equally (really) support C++, .NET, and Javascript, and to use whichever you&#039;re most comfortable with and meets your needs. If you&#039;re most familiar already with C# and are happy with its performance and environment, use it. If you&#039;re most familiar with C++ or want its extra efficiency and determinism (e.g., cleaning up WinRT stream objects efficiently and promptly by default), use it. Or write different parts of your app in all three; it works.

BTW also note that &quot;Metro style apps&quot; != &quot;Win8 tablet apps&quot; because the latter is a superset that also includes DirectX, for which you&#039;d want to use C++.]]></description>
		<content:encoded><![CDATA[<p>@Nikhil, @Rahul:</p>
<p>To develop Metro style apps, the Windows team&#8217;s guidance is that they equally (really) support C++, .NET, and Javascript, and to use whichever you&#8217;re most comfortable with and meets your needs. If you&#8217;re most familiar already with C# and are happy with its performance and environment, use it. If you&#8217;re most familiar with C++ or want its extra efficiency and determinism (e.g., cleaning up WinRT stream objects efficiently and promptly by default), use it. Or write different parts of your app in all three; it works.</p>
<p>BTW also note that &#8220;Metro style apps&#8221; != &#8220;Win8 tablet apps&#8221; because the latter is a superset that also includes DirectX, for which you&#8217;d want to use C++.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on C++11 &#8220;GoingNative 2012&#8221;: Speakers and Sessions by Charles</title>
		<link>http://herbsutter.com/2012/01/16/c11-goingnative-2012-speakers-and-sessions/#comment-4742</link>
		<dc:creator><![CDATA[Charles]]></dc:creator>
		<pubDate>Sat, 28 Jan 2012 21:08:51 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1322#comment-4742</guid>
		<description><![CDATA[@Tom: What Herb said :) 

Also, I&#039;ve updated http://channel9.msdn.com/Events/GoingNative/GoingNative-2012 to make this distinction very clear.

Charles]]></description>
		<content:encoded><![CDATA[<p>@Tom: What Herb said :) </p>
<p>Also, I&#8217;ve updated <a href="http://channel9.msdn.com/Events/GoingNative/GoingNative-2012" rel="nofollow">http://channel9.msdn.com/Events/GoingNative/GoingNative-2012</a> to make this distinction very clear.</p>
<p>Charles</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #103: Smart Pointers, Part 1 (Difficulty: 3/10) by Paul Michalik</title>
		<link>http://herbsutter.com/2012/01/20/gotw-103-smart-pointers-part-1-difficulty-310/#comment-4740</link>
		<dc:creator><![CDATA[Paul Michalik]]></dc:creator>
		<pubDate>Sat, 28 Jan 2012 09:55:54 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1346#comment-4740</guid>
		<description><![CDATA[I can&#039;t add anything more that has been said above to the answers regarding the actual question. One point though, as an addition to Waldemar Pawlaszek&#039;s comment. There are situations when you can&#039;t use the full power of currently standardized smart pointers: When you need to pass resources between independently compiled components. &quot;Independent&quot; means possibly compiled with different versions of std implementations (with different implementation of std::shared_ptr &amp; friends) and/or linked against different run-time libraries. From such a component, you typically do not export the definition of T at all, so there is no way to construct with the aid of make_shared. That&#039;s when (at least to some extent) boost::intrusive_ptr jumps in, leaving the resource lifetime management completely up to the implementation.]]></description>
		<content:encoded><![CDATA[<p>I can&#8217;t add anything more that has been said above to the answers regarding the actual question. One point though, as an addition to Waldemar Pawlaszek&#8217;s comment. There are situations when you can&#8217;t use the full power of currently standardized smart pointers: When you need to pass resources between independently compiled components. &#8220;Independent&#8221; means possibly compiled with different versions of std implementations (with different implementation of std::shared_ptr &amp; friends) and/or linked against different run-time libraries. From such a component, you typically do not export the definition of T at all, so there is no way to construct with the aid of make_shared. That&#8217;s when (at least to some extent) boost::intrusive_ptr jumps in, leaving the resource lifetime management completely up to the implementation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GoingNative 2012: Minus One Week by fabiogaluppo</title>
		<link>http://herbsutter.com/2012/01/26/goingnative-2012-minus-one-week/#comment-4733</link>
		<dc:creator><![CDATA[fabiogaluppo]]></dc:creator>
		<pubDate>Fri, 27 Jan 2012 10:41:08 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1351#comment-4733</guid>
		<description><![CDATA[Great news!!! I&#039;ll be there... arriving from Brazil]]></description>
		<content:encoded><![CDATA[<p>Great news!!! I&#8217;ll be there&#8230; arriving from Brazil</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #102: Exception-Safe Function Calls (Difficulty: 7/10) by Alf P. Steinbach</title>
		<link>http://herbsutter.com/gotw/_102/#comment-4730</link>
		<dc:creator><![CDATA[Alf P. Steinbach]]></dc:creator>
		<pubDate>Wed, 25 Jan 2012 13:51:52 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?page_id=1327#comment-4730</guid>
		<description><![CDATA[@herb: by &quot;free function&quot; to be replaced with a constructor, I meant &lt;code&gt;make_unique&lt;/code&gt;. Sorry but Wordpress is not perfect wrt. offering editing of user comments.

Cheers,

- Alf]]></description>
		<content:encoded><![CDATA[<p>@herb: by &#8220;free function&#8221; to be replaced with a constructor, I meant <code>make_unique</code>. Sorry but WordPress is not perfect wrt. offering editing of user comments.</p>
<p>Cheers,</p>
<p>- Alf</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #102: Exception-Safe Function Calls (Difficulty: 7/10) by Alf P. Steinbach</title>
		<link>http://herbsutter.com/gotw/_102/#comment-4729</link>
		<dc:creator><![CDATA[Alf P. Steinbach]]></dc:creator>
		<pubDate>Wed, 25 Jan 2012 13:45:18 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?page_id=1327#comment-4729</guid>
		<description><![CDATA[@Herb: For &lt;code&gt;f&lt;/code&gt; to be unsafe it is enough that &lt;code&gt;f&lt;/code&gt; &lt;em&gt;can&lt;/em&gt; be called without using &lt;code&gt;make_unique&lt;/code&gt;.

Relying on the user realzing and remembering that &lt;code&gt;make_unique&lt;/code&gt; should be used, is to rely on convention.

That&#039;s always risky, and to be avoided when the convention can very easily be expressed and enforced within the language (in this case, by replacing the free function with a constructor, andly changing the function signature accordingly).

Cheers &amp; hth.,

- Alf

PS: Again, thanks for keeping up this eris,]]></description>
		<content:encoded><![CDATA[<p>@Herb: For <code>f</code> to be unsafe it is enough that <code>f</code> <em>can</em> be called without using <code>make_unique</code>.</p>
<p>Relying on the user realzing and remembering that <code>make_unique</code> should be used, is to rely on convention.</p>
<p>That&#8217;s always risky, and to be avoided when the convention can very easily be expressed and enforced within the language (in this case, by replacing the free function with a constructor, andly changing the function signature accordingly).</p>
<p>Cheers &amp; hth.,</p>
<p>- Alf</p>
<p>PS: Again, thanks for keeping up this eris,</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #102: Exception-Safe Function Calls (Difficulty: 7/10) by Michael</title>
		<link>http://herbsutter.com/gotw/_102/#comment-4727</link>
		<dc:creator><![CDATA[Michael]]></dc:creator>
		<pubDate>Tue, 24 Jan 2012 21:13:34 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?page_id=1327#comment-4727</guid>
		<description><![CDATA[@Chris - The point that confuses me about 1(b) is this: &quot;For example, no part of the evaluation of expr2 or any of the execution of h may occur from the time g begins until it ends&quot;.

Consider an expression

f( !expr1, -expr2 );

If I read Herb correctly, the execution of operator!() and operator-() is unsequenced and allowed to overlap if the operators are built-in (e.g. if expr1 and exp2 are int), but is indeterminately sequenced and not allowed to overlap if the operators are user-defined. This looks counter-intuitive so I want to make sure my understanding is correct.]]></description>
		<content:encoded><![CDATA[<p>@Chris &#8211; The point that confuses me about 1(b) is this: &#8220;For example, no part of the evaluation of expr2 or any of the execution of h may occur from the time g begins until it ends&#8221;.</p>
<p>Consider an expression</p>
<p>f( !expr1, -expr2 );</p>
<p>If I read Herb correctly, the execution of operator!() and operator-() is unsequenced and allowed to overlap if the operators are built-in (e.g. if expr1 and exp2 are int), but is indeterminately sequenced and not allowed to overlap if the operators are user-defined. This looks counter-intuitive so I want to make sure my understanding is correct.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #102: Exception-Safe Function Calls (Difficulty: 7/10) by Chris Blume</title>
		<link>http://herbsutter.com/gotw/_102/#comment-4726</link>
		<dc:creator><![CDATA[Chris Blume]]></dc:creator>
		<pubDate>Tue, 24 Jan 2012 14:41:54 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?page_id=1327#comment-4726</guid>
		<description><![CDATA[@Michael - Yes, g( expr1 ) is still an expression in its own right. However, the key here is that before each function call all parameters must be fully evaluated.
f( g( expr1 ), h( expr2 ) );
g and h must be evaluated before f is called
expr1 must be evaluated before g is called
expr2 must be evaluated before h is called

That means expr1 and expr2 can still be executed in whatever order.
Case 1: expr1, expr2, g, h, f
Case 2: expr2, expr1, g, h, f
Either way still meets the guarantee that the expressions will have been fully evaluated before the functions are called. (This is opposed to, say, assuming arguments will be evaluated left-to-right.)

In case 1 for example, you could have: new T2, new T1 (throws)(cleans up this T1 instance), T2 was not cleaned. Plus what Herb mentioned about the new actually breaking into allocate and constructor pieces.


Thanks for the great insight, Herb!]]></description>
		<content:encoded><![CDATA[<p>@Michael &#8211; Yes, g( expr1 ) is still an expression in its own right. However, the key here is that before each function call all parameters must be fully evaluated.<br />
f( g( expr1 ), h( expr2 ) );<br />
g and h must be evaluated before f is called<br />
expr1 must be evaluated before g is called<br />
expr2 must be evaluated before h is called</p>
<p>That means expr1 and expr2 can still be executed in whatever order.<br />
Case 1: expr1, expr2, g, h, f<br />
Case 2: expr2, expr1, g, h, f<br />
Either way still meets the guarantee that the expressions will have been fully evaluated before the functions are called. (This is opposed to, say, assuming arguments will be evaluated left-to-right.)</p>
<p>In case 1 for example, you could have: new T2, new T1 (throws)(cleans up this T1 instance), T2 was not cleaned. Plus what Herb mentioned about the new actually breaking into allocate and constructor pieces.</p>
<p>Thanks for the great insight, Herb!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #103: Smart Pointers, Part 1 (Difficulty: 3/10) by Martin</title>
		<link>http://herbsutter.com/2012/01/20/gotw-103-smart-pointers-part-1-difficulty-310/#comment-4725</link>
		<dc:creator><![CDATA[Martin]]></dc:creator>
		<pubDate>Tue, 24 Jan 2012 10:46:32 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1346#comment-4725</guid>
		<description><![CDATA[3. What’s the deal with auto_ptr? -- Apart from it&#039;s standard set of problems, auto_ptr is completely broken in VC8 / VS2005, which unfortunately is still my compiler at work. 

In VC8 the statement:  auto_ptr(T) = new T();  // will compile and crash at runtime. Note that I&#039;ve replaced the angle brackets for posting purposes.]]></description>
		<content:encoded><![CDATA[<p>3. What’s the deal with auto_ptr? &#8212; Apart from it&#8217;s standard set of problems, auto_ptr is completely broken in VC8 / VS2005, which unfortunately is still my compiler at work. </p>
<p>In VC8 the statement:  auto_ptr(T) = new T();  // will compile and crash at runtime. Note that I&#8217;ve replaced the angle brackets for posting purposes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #102: Exception-Safe Function Calls (Difficulty: 7/10) by robdesbois</title>
		<link>http://herbsutter.com/gotw/_102/#comment-4719</link>
		<dc:creator><![CDATA[robdesbois]]></dc:creator>
		<pubDate>Mon, 23 Jan 2012 14:27:33 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?page_id=1327#comment-4719</guid>
		<description><![CDATA[@Alf - I can&#039;t see your original solution you refer to; could you repost or clarify here please? I cannot see why f() would be unsafe if it is accepting 2 unique_ptr arguments...unless you mean that the most natural way to call it is without using make_unique?

Thanks Herb :-)]]></description>
		<content:encoded><![CDATA[<p>@Alf &#8211; I can&#8217;t see your original solution you refer to; could you repost or clarify here please? I cannot see why f() would be unsafe if it is accepting 2 unique_ptr arguments&#8230;unless you mean that the most natural way to call it is without using make_unique?</p>
<p>Thanks Herb :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #103: Smart Pointers, Part 1 (Difficulty: 3/10) by Waldemar Pawlaszek</title>
		<link>http://herbsutter.com/2012/01/20/gotw-103-smart-pointers-part-1-difficulty-310/#comment-4714</link>
		<dc:creator><![CDATA[Waldemar Pawlaszek]]></dc:creator>
		<pubDate>Mon, 23 Jan 2012 08:15:14 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1346#comment-4714</guid>
		<description><![CDATA[@Kerrek SB: The question was not about constructing shared pointer but about allocating a memory for and constructing an object that is to be managed by shared_ptr. When the object is already constructed there is no use for the make_shared utility.

On the other hand in my work I&#039;ve recognized two problems with make_shared:
1. You cannot use make_shared with classes that have protected constructor. It is essential when the class have it&#039;s own &quot;create&quot; factory performing some additional work and we want to disallow the means for creating the object outside of the factory. Standard does not specify with who to be befriended (and even if, it would create a loophole) and there is no base class to inherit from that would do the work effectively.
2. When weak_ptr outlives shared_ptr the memory that have been occupied by the object can&#039;t be freed until all weak pointers will be destroyed.]]></description>
		<content:encoded><![CDATA[<p>@Kerrek SB: The question was not about constructing shared pointer but about allocating a memory for and constructing an object that is to be managed by shared_ptr. When the object is already constructed there is no use for the make_shared utility.</p>
<p>On the other hand in my work I&#8217;ve recognized two problems with make_shared:<br />
1. You cannot use make_shared with classes that have protected constructor. It is essential when the class have it&#8217;s own &#8220;create&#8221; factory performing some additional work and we want to disallow the means for creating the object outside of the factory. Standard does not specify with who to be befriended (and even if, it would create a loophole) and there is no base class to inherit from that would do the work effectively.<br />
2. When weak_ptr outlives shared_ptr the memory that have been occupied by the object can&#8217;t be freed until all weak pointers will be destroyed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #102: Exception-Safe Function Calls (Difficulty: 7/10) by CM</title>
		<link>http://herbsutter.com/gotw/_102/#comment-4713</link>
		<dc:creator><![CDATA[CM]]></dc:creator>
		<pubDate>Mon, 23 Jan 2012 02:51:37 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?page_id=1327#comment-4713</guid>
		<description><![CDATA[Blog software ate all angle brackets. Here is pastebin version: http://pastebin.com/ufRE5Snj .]]></description>
		<content:encoded><![CDATA[<p>Blog software ate all angle brackets. Here is pastebin version: <a href="http://pastebin.com/ufRE5Snj" rel="nofollow">http://pastebin.com/ufRE5Snj</a> .</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #102: Exception-Safe Function Calls (Difficulty: 7/10) by CM</title>
		<link>http://herbsutter.com/gotw/_102/#comment-4712</link>
		<dc:creator><![CDATA[CM]]></dc:creator>
		<pubDate>Mon, 23 Jan 2012 02:48:47 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?page_id=1327#comment-4712</guid>
		<description><![CDATA[Just checked both GCC and MSVC2010 -- in both cases adding make_unique causes magic of RVO to disappear. I suspect this has something to do with the fact that to allocate an object we use &#039;statement new&#039; (as opposed to &#039;operator new&#039;) and certain rules about sequence points do not apply to it (thus allowing RVO to work).
I.e. perfect forwarding actually is not perfect :-) -- in order for it to become perfect we need a way to declare that make_unique is not a function, but a statement.
I hope that make_shared/make_unique in future C++ will get special status similar to statement new.

Here is test code, if anyone wants to trcheck:

#include 
#include 
#include 
#include 

using namespace std;

struct A
{
    int m;
    A(int i) : m(i) { printf(&quot;ctor(%d)\n&quot;, i); }
    A(A const&amp; o) : m(o.m) { printf(&quot;cctor(%d)\n&quot;, o.m); }
    A const&amp; operator=(A const&amp; o){ m = o.m; printf(&quot;op=(%d)\n&quot;, o.m); }
    ~A() { printf(&quot;dtor\n&quot;); }
};

A foo() { return A( rand() ); }
auto_ptr&lt;A&gt; make_unique(A&amp;&amp; a) { return auto_ptr&lt;A&gt;(new A(forward&lt;A&gt;(a))); }
//unique_ptr&lt;A&gt; make_unique(A&amp;&amp; a) { return unique_ptr&lt;A&gt;(new A(forward&lt;A&gt;(a))); }

int main()
{
	srand(time(NULL));
    auto_ptr&lt;A&gt; p( new A(foo()) );
//    auto_ptr&lt;A&gt; p( make_unique(foo()) );
//    unique_ptr&lt;A&gt; p( make_unique(foo()) );
    return 1;
}]]></description>
		<content:encoded><![CDATA[<p>Just checked both GCC and MSVC2010 &#8212; in both cases adding make_unique causes magic of RVO to disappear. I suspect this has something to do with the fact that to allocate an object we use &#8216;statement new&#8217; (as opposed to &#8216;operator new&#8217;) and certain rules about sequence points do not apply to it (thus allowing RVO to work).<br />
I.e. perfect forwarding actually is not perfect :-) &#8212; in order for it to become perfect we need a way to declare that make_unique is not a function, but a statement.<br />
I hope that make_shared/make_unique in future C++ will get special status similar to statement new.</p>
<p>Here is test code, if anyone wants to trcheck:</p>
<p>#include<br />
#include<br />
#include<br />
#include </p>
<p>using namespace std;</p>
<p>struct A<br />
{<br />
    int m;<br />
    A(int i) : m(i) { printf(&#8220;ctor(%d)\n&#8221;, i); }<br />
    A(A const&amp; o) : m(o.m) { printf(&#8220;cctor(%d)\n&#8221;, o.m); }<br />
    A const&amp; operator=(A const&amp; o){ m = o.m; printf(&#8220;op=(%d)\n&#8221;, o.m); }<br />
    ~A() { printf(&#8220;dtor\n&#8221;); }<br />
};</p>
<p>A foo() { return A( rand() ); }<br />
auto_ptr<a> make_unique(A&amp;&amp; a) { return auto_ptr</a><a>(new A(forward</a><a>(a))); }<br />
//unique_ptr</a><a> make_unique(A&amp;&amp; a) { return unique_ptr</a><a>(new A(forward</a><a>(a))); }</p>
<p>int main()<br />
{<br />
	srand(time(NULL));<br />
    auto_ptr</a><a> p( new A(foo()) );<br />
//    auto_ptr</a><a> p( make_unique(foo()) );<br />
//    unique_ptr</a><a> p( make_unique(foo()) );<br />
    return 1;<br />
}</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #103: Smart Pointers, Part 1 (Difficulty: 3/10) by Kerrek SB</title>
		<link>http://herbsutter.com/2012/01/20/gotw-103-smart-pointers-part-1-difficulty-310/#comment-4711</link>
		<dc:creator><![CDATA[Kerrek SB]]></dc:creator>
		<pubDate>Mon, 23 Jan 2012 02:13:15 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1346#comment-4711</guid>
		<description><![CDATA[To add to the much belaboured point 2:

One further situation in which you don&#039;t use `make_shared` is when constructing a shared pointer *from* an existing unique pointer, possibly with a non-default deleter. The resulting shared pointer will have to be one of the type with separate refcontrol block (including the deleter information) and distinct dynamic resource (which already comes fully furnished from the unique pointer).

Interestingly enough, the construction-from-unique&amp;&amp; doesn&#039;t appear to allow you to specify an allocator.]]></description>
		<content:encoded><![CDATA[<p>To add to the much belaboured point 2:</p>
<p>One further situation in which you don&#8217;t use `make_shared` is when constructing a shared pointer *from* an existing unique pointer, possibly with a non-default deleter. The resulting shared pointer will have to be one of the type with separate refcontrol block (including the deleter information) and distinct dynamic resource (which already comes fully furnished from the unique pointer).</p>
<p>Interestingly enough, the construction-from-unique&amp;&amp; doesn&#8217;t appear to allow you to specify an allocator.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #102: Exception-Safe Function Calls (Difficulty: 7/10) by Alf P. Steinbach</title>
		<link>http://herbsutter.com/gotw/_102/#comment-4709</link>
		<dc:creator><![CDATA[Alf P. Steinbach]]></dc:creator>
		<pubDate>Sun, 22 Jan 2012 23:52:56 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?page_id=1327#comment-4709</guid>
		<description><![CDATA[As I discussed in my proposed solution, while the &lt;em&gt;call&lt;/em&gt; to &lt;code&gt;f&lt;/code&gt; is now safe enough, &lt;code&gt;f&lt;/code&gt; is still as unsafe as ever.

It is still not just possible, but &lt;em&gt;most natural&lt;/em&gt;, to call &lt;code&gt;f&lt;/code&gt; in an unsafe way.

And one solution is to replace the &lt;code&gt;make_unique&lt;/code&gt; function with a &lt;code&gt;Unique&lt;/code&gt; class whose constructor does the same as &lt;code&gt;make_unique&lt;/code&gt; (namely forwarding arguments and doing the &lt;code&gt;new&lt;/code&gt;&#039;ing), and use this class for the formal arguments of &lt;code&gt;f&lt;/code&gt;.

Cheers &amp; hth., &amp; thanks for keeping up the GOTW series!, :-)

- Alf]]></description>
		<content:encoded><![CDATA[<p>As I discussed in my proposed solution, while the <em>call</em> to <code>f</code> is now safe enough, <code>f</code> is still as unsafe as ever.</p>
<p>It is still not just possible, but <em>most natural</em>, to call <code>f</code> in an unsafe way.</p>
<p>And one solution is to replace the <code>make_unique</code> function with a <code>Unique</code> class whose constructor does the same as <code>make_unique</code> (namely forwarding arguments and doing the <code>new</code>&#8216;ing), and use this class for the formal arguments of <code>f</code>.</p>
<p>Cheers &amp; hth., &amp; thanks for keeping up the GOTW series!, :-)</p>
<p>- Alf</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #102: Exception-Safe Function Calls (Difficulty: 7/10) by Alf P. Steinbach</title>
		<link>http://herbsutter.com/gotw/_102/#comment-4708</link>
		<dc:creator><![CDATA[Alf P. Steinbach]]></dc:creator>
		<pubDate>Sun, 22 Jan 2012 23:51:25 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?page_id=1327#comment-4708</guid>
		<description><![CDATA[As I discussed in my proposed solution, while the &lt;em&gt;call&lt;/em&gt; to &lt;code&gt;f&lt;/code&gt; is now safe enough, &lt;code&gt;f&lt;/code&gt; is still as unsafe as ever.

It is still not just possible, but &lt;em&gt;most natural&lt;em&gt;, to call &lt;code&gt;f&lt;/code&gt; in an unsafe way.

And one solution is to replace the &lt;code&gt;make_unique&lt;/code&gt; function with a &lt;code&gt;Unique&lt;/code&gt; class whose constructor does the same as &lt;code&gt;make_unique&lt;/code&gt; (namely forwarding arguments and doing the &lt;code&gt;new&lt;/code&gt;&#039;ing), and use this class for the formal arguments of &lt;code&gt;f&lt;/code&gt;.

Cheers &amp; hth., &amp; thanks for keeping up the GOTW series!, :-)

- Alf]]></description>
		<content:encoded><![CDATA[<p>As I discussed in my proposed solution, while the <em>call</em> to <code>f</code> is now safe enough, <code>f</code> is still as unsafe as ever.</p>
<p>It is still not just possible, but <em>most natural</em><em>, to call <code>f</code> in an unsafe way.</p>
<p>And one solution is to replace the <code>make_unique</code> function with a <code>Unique</code> class whose constructor does the same as <code>make_unique</code> (namely forwarding arguments and doing the <code>new</code>&#8216;ing), and use this class for the formal arguments of <code>f</code>.</p>
<p>Cheers &amp; hth., &amp; thanks for keeping up the GOTW series!, :-)</p>
<p>- Alf</em></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #102: Exception-Safe Function Calls (Difficulty: 7/10) by CM</title>
		<link>http://herbsutter.com/gotw/_102/#comment-4706</link>
		<dc:creator><![CDATA[CM]]></dc:creator>
		<pubDate>Sun, 22 Jan 2012 20:39:54 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?page_id=1327#comment-4706</guid>
		<description><![CDATA[Correction: you should end up with unnecessary move constructor call (assuming your class has it). It is better, but still an unnecessary overhead.]]></description>
		<content:encoded><![CDATA[<p>Correction: you should end up with unnecessary move constructor call (assuming your class has it). It is better, but still an unnecessary overhead.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #102: Exception-Safe Function Calls (Difficulty: 7/10) by CM</title>
		<link>http://herbsutter.com/gotw/_102/#comment-4705</link>
		<dc:creator><![CDATA[CM]]></dc:creator>
		<pubDate>Sun, 22 Jan 2012 20:06:28 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?page_id=1327#comment-4705</guid>
		<description><![CDATA[I might be wrong, but there is an unfortunate side effect of &#039;make_unique&#039; trick:
- normally this construct utilizes RVO and avoids calling copy constructor:
    MyType foo() { return MyType(...); }
    MyType* p = new MyType( foo() );

logic suggest that it should not work (foo() call should complete before we allocate any memory and therefore we are doomed to have a copy), but it seems that major compilers (GCC/MSVC) recognize this situation and (unless you overload operator new) go extra mile and allow RVO to work here (or may be there is an obscure clause in C++ standard that allows that).

- unfortunately &#039;make_unique&#039; facility will break it and this will leave you with unnecessary copy constructor call:

    auto p = make_unique(foo());

Disclaimer: I reserve my right to be wrong. :-)]]></description>
		<content:encoded><![CDATA[<p>I might be wrong, but there is an unfortunate side effect of &#8216;make_unique&#8217; trick:<br />
- normally this construct utilizes RVO and avoids calling copy constructor:<br />
    MyType foo() { return MyType(&#8230;); }<br />
    MyType* p = new MyType( foo() );</p>
<p>logic suggest that it should not work (foo() call should complete before we allocate any memory and therefore we are doomed to have a copy), but it seems that major compilers (GCC/MSVC) recognize this situation and (unless you overload operator new) go extra mile and allow RVO to work here (or may be there is an obscure clause in C++ standard that allows that).</p>
<p>- unfortunately &#8216;make_unique&#8217; facility will break it and this will leave you with unnecessary copy constructor call:</p>
<p>    auto p = make_unique(foo());</p>
<p>Disclaimer: I reserve my right to be wrong. :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #102: Exception-Safe Function Calls (Difficulty: 7/10) by Michael</title>
		<link>http://herbsutter.com/gotw/_102/#comment-4703</link>
		<dc:creator><![CDATA[Michael]]></dc:creator>
		<pubDate>Sun, 22 Jan 2012 10:51:37 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?page_id=1327#comment-4703</guid>
		<description><![CDATA[Why is there any difference between 1(a) and 1(b)? Is wrapping an expression into a function call makes it a non-expression? I.e. is g( expr1 ) not an expression in its own right?]]></description>
		<content:encoded><![CDATA[<p>Why is there any difference between 1(a) and 1(b)? Is wrapping an expression into a function call makes it a non-expression? I.e. is g( expr1 ) not an expression in its own right?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #103: Smart Pointers, Part 1 (Difficulty: 3/10) by Bartosz Milewski</title>
		<link>http://herbsutter.com/2012/01/20/gotw-103-smart-pointers-part-1-difficulty-310/#comment-4702</link>
		<dc:creator><![CDATA[Bartosz Milewski]]></dc:creator>
		<pubDate>Sat, 21 Jan 2012 22:30:27 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1346#comment-4702</guid>
		<description><![CDATA[I&#039;d like to clarify one point: the distinction between strong and weak pointers. 

When using unique_ptr, there is only one owner of the resource at a time. However, unique_ptr may grant non-owning access to its resource. This is very important when, e.g., you want to call a library function that takes a pointer to your resource:
&lt;pre&gt;libFun(Foo *);
unique_ptr foo(new Foo);
libFun(foo.get());&lt;/pre&gt;
By &quot;library&quot; I mean any reusable code. It makes very little sense to have a library function that operates of Foo, but has no interest in the ownership of Foo, to have this signature:
&lt;pre&gt;libFun(unique_ptr &amp; foo);&lt;/pre&gt;
The pointer passed to libFun(Foo*) is a transient alias, or a &quot;weak pointer&quot; to the resource. It&#039;s a bad idea to let the function or a data structure store such a transient alias for two reasons: (1) The alias might become invalid when the owner is destroyed, (2) such aliases might appear in a different thread than the owner&#039;s. In the latter case, thread safety of a unique_ptr is compromised. A unique_ptr is thread-safe only if there are no aliases to it or to its contents (transitively), and there are no aliases inside its contents to data that&#039;s accessible from the outside. In general, a unique_ptr defines its own cluster of interlinked objects that have no connection to the outside (incoming or outgoing references). 

When using shared_ptr, many copies of it might coexist in the program at the same time. It&#039;s still not a good idea to store aliases to the resource it&#039;s protecting or to its transitive contents. 

shared_ptr implements a simple form of garbage collection -- reference counting. The problem with reference counting is that it doesn&#039;t deal well with cycles. If you have a graph data structure that contains back pointers, you can&#039;t turn them into shared_ptrs without risking cycles. The semi-safe way to implement back pointers in a shared_ptr-based data structure is to use weak_ptr. A weak_ptr doesn&#039;t take part in reference counting, so it doesn&#039;t create non-collectible cycles, but it can be (temporarily) converted into a shared_ptr to gain access to the resource. (Of course, if the resource has already been collected, this conversion will not work and it will result in an exception.) weak_ptrs are used, for instance, in shareable doubly-linked lists or trees with parent pointers.]]></description>
		<content:encoded><![CDATA[<p>I&#8217;d like to clarify one point: the distinction between strong and weak pointers. </p>
<p>When using unique_ptr, there is only one owner of the resource at a time. However, unique_ptr may grant non-owning access to its resource. This is very important when, e.g., you want to call a library function that takes a pointer to your resource:</p>
<pre>libFun(Foo *);
unique_ptr foo(new Foo);
libFun(foo.get());</pre>
<p>By &#8220;library&#8221; I mean any reusable code. It makes very little sense to have a library function that operates of Foo, but has no interest in the ownership of Foo, to have this signature:</p>
<pre>libFun(unique_ptr &amp; foo);</pre>
<p>The pointer passed to libFun(Foo*) is a transient alias, or a &#8220;weak pointer&#8221; to the resource. It&#8217;s a bad idea to let the function or a data structure store such a transient alias for two reasons: (1) The alias might become invalid when the owner is destroyed, (2) such aliases might appear in a different thread than the owner&#8217;s. In the latter case, thread safety of a unique_ptr is compromised. A unique_ptr is thread-safe only if there are no aliases to it or to its contents (transitively), and there are no aliases inside its contents to data that&#8217;s accessible from the outside. In general, a unique_ptr defines its own cluster of interlinked objects that have no connection to the outside (incoming or outgoing references). </p>
<p>When using shared_ptr, many copies of it might coexist in the program at the same time. It&#8217;s still not a good idea to store aliases to the resource it&#8217;s protecting or to its transitive contents. </p>
<p>shared_ptr implements a simple form of garbage collection &#8212; reference counting. The problem with reference counting is that it doesn&#8217;t deal well with cycles. If you have a graph data structure that contains back pointers, you can&#8217;t turn them into shared_ptrs without risking cycles. The semi-safe way to implement back pointers in a shared_ptr-based data structure is to use weak_ptr. A weak_ptr doesn&#8217;t take part in reference counting, so it doesn&#8217;t create non-collectible cycles, but it can be (temporarily) converted into a shared_ptr to gain access to the resource. (Of course, if the resource has already been collected, this conversion will not work and it will result in an exception.) weak_ptrs are used, for instance, in shareable doubly-linked lists or trees with parent pointers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #102: Exception-Safe Function Calls (Difficulty: 7/10) by Victor</title>
		<link>http://herbsutter.com/gotw/_102/#comment-4700</link>
		<dc:creator><![CDATA[Victor]]></dc:creator>
		<pubDate>Sat, 21 Jan 2012 15:05:55 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?page_id=1327#comment-4700</guid>
		<description><![CDATA[Wow. Thanks a lot!]]></description>
		<content:encoded><![CDATA[<p>Wow. Thanks a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #102: Exception-Safe Function Calls (Difficulty: 7/10) by Nick Form</title>
		<link>http://herbsutter.com/gotw/_102/#comment-4696</link>
		<dc:creator><![CDATA[Nick Form]]></dc:creator>
		<pubDate>Sat, 21 Jan 2012 06:26:44 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?page_id=1327#comment-4696</guid>
		<description><![CDATA[Thanks, learned a lot.]]></description>
		<content:encoded><![CDATA[<p>Thanks, learned a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #103: Smart Pointers, Part 1 (Difficulty: 3/10) by Alfonse</title>
		<link>http://herbsutter.com/2012/01/20/gotw-103-smart-pointers-part-1-difficulty-310/#comment-4695</link>
		<dc:creator><![CDATA[Alfonse]]></dc:creator>
		<pubDate>Sat, 21 Jan 2012 03:45:56 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1346#comment-4695</guid>
		<description><![CDATA[1: When should you use shared_ptr vs. unique_ptr? List as many considerations as you can.

unique_ptr should be used for situations where a function or object needs to allocate something, but does not need to share ownership of that allocated object with some other object or function. The object/function will directly control the lifetime of the object.

unique_ptr should be used in situations where ownership can be *given* to another object/function. That is, after the function call, the current owner no longer has access to it anymore.

shared_ptr should be used in situations where multiple functions/objects can *simultaneously* claim ownership to the same allocated resource.

shared_ptr should also be used in situations where other functions/objects may want to weakly reference an object. This is useful for objects that need to monitor other objects, but don&#039;t fully claim ownership over the lifetime of that object. The object with the weak reference can check to see if the object still exists, but it does not prevent it from being destroyed.

2: Why should you always use make_shared to allocate objects whose lifetimes will be managed by shared_ptr? Explain.

shared_ptr offers a number of features. The main one is the ability for multiple copies of the shared_ptr to all claim ownership of the same object. In order to do this, shared_ptr requires a special control block of memory that stores a count of references to the managed pointer. This block is separate from the actual pointer being owned.

Consider the following.

auto variable = shared_ptr(new Typename);

Two memory allocations happen. `new Typename` allocates the object that will be owned. But the constructor of the shared_ptr also allocates the control block which contains the reference count. That is two separate allocations.

Since memory allocation is not exactly a lightweight activity, it is best to minimize it. Because make_shared does the construction of the type, it has the ability to combine the memory for the object and the control block into one allocation.

Therefore, where *possible*, it is best to use make_shared. However, it is not always possible. It cannot be used for managing memory from a source that is not a C++ object, such as an opaque pointer returned from a C-style API.

allocate_shared should be used in circumstances where a special memory allocator is needed.

So the question itself presupposes a conclusion that is incorrect, since make_shared cannot replace *all* uses of shared_ptr creation.

3: What’s the deal with auto_ptr?

auto_ptr was an attempt to replicate the effective functionality of unique_ptr using a language that couldn&#039;t express true move semantics. Its copy constructor actually *moved* the ownership rather than copying it.

One can make reasonably safe use of auto_ptr if one is careful. However, it cannot be used in a standard libary container due to its &quot;copying&quot; semantics. Standard containers that copy their elements at any time could easily break any stored auto_ptr. Something similar can happen for storing auto_ptr in an object without a specialized copy constructor/assignment operator.

Since unique_ptr uses C++11 features to explicitly disallow copying, and C++11 standard containers can store non-copyable objects via use of move constructors, auto_ptr is effectiveless useless. It was therefore deprecated in C++11.]]></description>
		<content:encoded><![CDATA[<p>1: When should you use shared_ptr vs. unique_ptr? List as many considerations as you can.</p>
<p>unique_ptr should be used for situations where a function or object needs to allocate something, but does not need to share ownership of that allocated object with some other object or function. The object/function will directly control the lifetime of the object.</p>
<p>unique_ptr should be used in situations where ownership can be *given* to another object/function. That is, after the function call, the current owner no longer has access to it anymore.</p>
<p>shared_ptr should be used in situations where multiple functions/objects can *simultaneously* claim ownership to the same allocated resource.</p>
<p>shared_ptr should also be used in situations where other functions/objects may want to weakly reference an object. This is useful for objects that need to monitor other objects, but don&#8217;t fully claim ownership over the lifetime of that object. The object with the weak reference can check to see if the object still exists, but it does not prevent it from being destroyed.</p>
<p>2: Why should you always use make_shared to allocate objects whose lifetimes will be managed by shared_ptr? Explain.</p>
<p>shared_ptr offers a number of features. The main one is the ability for multiple copies of the shared_ptr to all claim ownership of the same object. In order to do this, shared_ptr requires a special control block of memory that stores a count of references to the managed pointer. This block is separate from the actual pointer being owned.</p>
<p>Consider the following.</p>
<p>auto variable = shared_ptr(new Typename);</p>
<p>Two memory allocations happen. `new Typename` allocates the object that will be owned. But the constructor of the shared_ptr also allocates the control block which contains the reference count. That is two separate allocations.</p>
<p>Since memory allocation is not exactly a lightweight activity, it is best to minimize it. Because make_shared does the construction of the type, it has the ability to combine the memory for the object and the control block into one allocation.</p>
<p>Therefore, where *possible*, it is best to use make_shared. However, it is not always possible. It cannot be used for managing memory from a source that is not a C++ object, such as an opaque pointer returned from a C-style API.</p>
<p>allocate_shared should be used in circumstances where a special memory allocator is needed.</p>
<p>So the question itself presupposes a conclusion that is incorrect, since make_shared cannot replace *all* uses of shared_ptr creation.</p>
<p>3: What’s the deal with auto_ptr?</p>
<p>auto_ptr was an attempt to replicate the effective functionality of unique_ptr using a language that couldn&#8217;t express true move semantics. Its copy constructor actually *moved* the ownership rather than copying it.</p>
<p>One can make reasonably safe use of auto_ptr if one is careful. However, it cannot be used in a standard libary container due to its &#8220;copying&#8221; semantics. Standard containers that copy their elements at any time could easily break any stored auto_ptr. Something similar can happen for storing auto_ptr in an object without a specialized copy constructor/assignment operator.</p>
<p>Since unique_ptr uses C++11 features to explicitly disallow copying, and C++11 standard containers can store non-copyable objects via use of move constructors, auto_ptr is effectiveless useless. It was therefore deprecated in C++11.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #103: Smart Pointers, Part 1 (Difficulty: 3/10) by Bartosz Milewski</title>
		<link>http://herbsutter.com/2012/01/20/gotw-103-smart-pointers-part-1-difficulty-310/#comment-4693</link>
		<dc:creator><![CDATA[Bartosz Milewski]]></dc:creator>
		<pubDate>Fri, 20 Jan 2012 23:09:34 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1346#comment-4693</guid>
		<description><![CDATA[1. Whenever the ownership of a resource (including heap-allocated memory) is well defined during the whole lifetime of the object, you should use unique_ptr. Ownership means responsibility for releasing the resource. Ownership may be passed by _moving_ unique_ptr.

Only if you can&#039;t clearly assign the owner to the resource should you use shared_ptr. This happens when access to a resource is shared between objects whose lifetimes cannot be predicted. shared_ptr implements the policy of &quot;last to leave the room turns off the lights&quot; (releases the resource).

In a multithreaded context, unique_ptr is the fastest and safest way of moving data between threads, as long as there are no stray aliases left behind. Uniqueness means that only one thread at a time has access to the resource and no additional synchronization is required. This is not true with shared_ptr, which facilitates sharing of resources between threads. The object in shared_ptr must implement its own synchronization. What shared_ptr provides is thread-safe reference counting, but at a non-trivial cost. 

2. make_shared is a substantial optimization. Normally a shared_ptr needs a separate heap object for storing the reference count. When shared_ptr is created using make_shared, the memory for the object and the reference count are allocated together. Besides saving one allocation, this also improves locality.

3. auto_ptr was a hack that is now deprecated. Move semantics and rvalue references allow clean and efficient implementation of unique_ptr. The major danger with auto_ptr is that it could be quietly passed using its copy constructor, which would invalidate the source auto_ptr. If that source auto_ptr was subsequently accessed, it would result in a fault. unique_ptr, on the other hand, cannot be passed quietly, unless it&#039;s an rvalue. The programmer has to explicitly call std::move to pass an lvalue unique_ptr. That makes for a safer code.]]></description>
		<content:encoded><![CDATA[<p>1. Whenever the ownership of a resource (including heap-allocated memory) is well defined during the whole lifetime of the object, you should use unique_ptr. Ownership means responsibility for releasing the resource. Ownership may be passed by _moving_ unique_ptr.</p>
<p>Only if you can&#8217;t clearly assign the owner to the resource should you use shared_ptr. This happens when access to a resource is shared between objects whose lifetimes cannot be predicted. shared_ptr implements the policy of &#8220;last to leave the room turns off the lights&#8221; (releases the resource).</p>
<p>In a multithreaded context, unique_ptr is the fastest and safest way of moving data between threads, as long as there are no stray aliases left behind. Uniqueness means that only one thread at a time has access to the resource and no additional synchronization is required. This is not true with shared_ptr, which facilitates sharing of resources between threads. The object in shared_ptr must implement its own synchronization. What shared_ptr provides is thread-safe reference counting, but at a non-trivial cost. </p>
<p>2. make_shared is a substantial optimization. Normally a shared_ptr needs a separate heap object for storing the reference count. When shared_ptr is created using make_shared, the memory for the object and the reference count are allocated together. Besides saving one allocation, this also improves locality.</p>
<p>3. auto_ptr was a hack that is now deprecated. Move semantics and rvalue references allow clean and efficient implementation of unique_ptr. The major danger with auto_ptr is that it could be quietly passed using its copy constructor, which would invalidate the source auto_ptr. If that source auto_ptr was subsequently accessed, it would result in a fault. unique_ptr, on the other hand, cannot be passed quietly, unless it&#8217;s an rvalue. The programmer has to explicitly call std::move to pass an lvalue unique_ptr. That makes for a safer code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #103: Smart Pointers, Part 1 (Difficulty: 3/10) by stackedcrooked</title>
		<link>http://herbsutter.com/2012/01/20/gotw-103-smart-pointers-part-1-difficulty-310/#comment-4692</link>
		<dc:creator><![CDATA[stackedcrooked]]></dc:creator>
		<pubDate>Fri, 20 Jan 2012 23:01:04 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1346#comment-4692</guid>
		<description><![CDATA[The `unique_ptr`:
- Ownership transfer. Factories should ideally return `unique_ptr` instead of raw pointers.
- Safely pass an object between threads (only one thread can access it at a time).
- Can be used as a holder for the impl object in the pimpl idiom.
- Can be used in containers thanks to move semantics. But it&#039;s not very flexible.
- Can be used for the similar purposes as `boost::scoped_ptr`.

The `shared_ptr`:
- Shared ownership. I usually prefer single ownership though.
- Safely store pointers in a container. More flexible than `unique_ptr` in this regard.
- parent-child relations can be modeled using `shared_ptr` and `weak_ptr`.
- Accepts a `free`-function as a second constructor argument.
- It generates a &#039;free&#039;-function based on the type provided in the constructor. So `shared_ptr ptr(new SubClass());` is safe even if `Base` does not have a virtual destructor.

Concerning `make_shared`:
- Safe alternative to unnamed `shared_ptr` temporaries (see [documentation of boost::shared_ptr](http://www.boost.org/doc/libs/1_48_0/libs/smart_ptr/shared_ptr.htm#BestPractices) ).
- It&#039;s a nicer and compacter syntax.

Concerning `auto_ptr`:
- Has similar use as `unique_ptr` (ownership transfer, passing between threads) or `boost::scoped_ptr`.
- Not safe to use in containers.
- Dangerous to use for member variables in classes do not have a user-defined copy constructor and assignment operator. Even though the class obeys the rule-of-three, it is not safe to copy because it leaves the original invalidated.

With `auto_ptr` it&#039;s easy to shoot yourself in the foot by passing it to a function and then still try to use it:

    std::auto_ptr r = foo();
    bar(r); // This looks like a regular function call.
    std::cout &lt;value(); // Ouch! I forgot the object is no longer accessible!

With `unique_ptr` you must explicitly move the pointer by calling `std::move`. This makes me less likely to forget that I can no longer access it:

    std::unique_ptr ptr = foo();
    bar(std::move(ptr)); // alerts me that the object is no longer accessible]]></description>
		<content:encoded><![CDATA[<p>The `unique_ptr`:<br />
- Ownership transfer. Factories should ideally return `unique_ptr` instead of raw pointers.<br />
- Safely pass an object between threads (only one thread can access it at a time).<br />
- Can be used as a holder for the impl object in the pimpl idiom.<br />
- Can be used in containers thanks to move semantics. But it&#8217;s not very flexible.<br />
- Can be used for the similar purposes as `boost::scoped_ptr`.</p>
<p>The `shared_ptr`:<br />
- Shared ownership. I usually prefer single ownership though.<br />
- Safely store pointers in a container. More flexible than `unique_ptr` in this regard.<br />
- parent-child relations can be modeled using `shared_ptr` and `weak_ptr`.<br />
- Accepts a `free`-function as a second constructor argument.<br />
- It generates a &#8216;free&#8217;-function based on the type provided in the constructor. So `shared_ptr ptr(new SubClass());` is safe even if `Base` does not have a virtual destructor.</p>
<p>Concerning `make_shared`:<br />
- Safe alternative to unnamed `shared_ptr` temporaries (see [documentation of boost::shared_ptr](http://www.boost.org/doc/libs/1_48_0/libs/smart_ptr/shared_ptr.htm#BestPractices) ).<br />
- It&#8217;s a nicer and compacter syntax.</p>
<p>Concerning `auto_ptr`:<br />
- Has similar use as `unique_ptr` (ownership transfer, passing between threads) or `boost::scoped_ptr`.<br />
- Not safe to use in containers.<br />
- Dangerous to use for member variables in classes do not have a user-defined copy constructor and assignment operator. Even though the class obeys the rule-of-three, it is not safe to copy because it leaves the original invalidated.</p>
<p>With `auto_ptr` it&#8217;s easy to shoot yourself in the foot by passing it to a function and then still try to use it:</p>
<p>    std::auto_ptr r = foo();<br />
    bar(r); // This looks like a regular function call.<br />
    std::cout &lt;value(); // Ouch! I forgot the object is no longer accessible!</p>
<p>With `unique_ptr` you must explicitly move the pointer by calling `std::move`. This makes me less likely to forget that I can no longer access it:</p>
<p>    std::unique_ptr ptr = foo();<br />
    bar(std::move(ptr)); // alerts me that the object is no longer accessible</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #103: Smart Pointers, Part 1 (Difficulty: 3/10) by Xeo</title>
		<link>http://herbsutter.com/2012/01/20/gotw-103-smart-pointers-part-1-difficulty-310/#comment-4691</link>
		<dc:creator><![CDATA[Xeo]]></dc:creator>
		<pubDate>Fri, 20 Jan 2012 21:16:18 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1346#comment-4691</guid>
		<description><![CDATA[1) &lt;a href=&quot;http://stackoverflow.com/q/8706192/500104&quot; rel=&quot;nofollow&quot;&gt;StackOverflow: Which kind of pointer do I use when?&lt;/a&gt; :)

2) Not always. &lt;em&gt;make_shared&lt;/em&gt; doesn&#039;t allow to specify your own deleter. However, if there is no need for one, then there are indeed good reasons to use it. For one, &lt;em&gt;make_shared&lt;/em&gt; compresses the allocations into a single one, where a &lt;em&gt;shared_ptr&lt;X&amp;rt; p(new X);&lt;/em&gt; would need two allocations: one for the &lt;em&gt;X&lt;/em&gt; object, one for the reference-count block used by the &lt;em&gt;shared_ptr&lt;/em&gt;.

3) &lt;em&gt;auto_ptr&lt;/em&gt; has broken copy semantics. The copies actually &lt;em&gt;moves&lt;/em&gt; the &lt;em&gt;auto_ptr&lt;/em&gt;, meaning it transfers the ownership on copy. As such, it&#039;s unusable in standard containers and even deprecated by the C++11 standard.]]></description>
		<content:encoded><![CDATA[<p>1) <a href="http://stackoverflow.com/q/8706192/500104" rel="nofollow">StackOverflow: Which kind of pointer do I use when?</a> :)</p>
<p>2) Not always. <em>make_shared</em> doesn&#8217;t allow to specify your own deleter. However, if there is no need for one, then there are indeed good reasons to use it. For one, <em>make_shared</em> compresses the allocations into a single one, where a <em>shared_ptr&lt;X&amp;rt; p(new X);</em> would need two allocations: one for the <em>X</em> object, one for the reference-count block used by the <em>shared_ptr</em>.</p>
<p>3) <em>auto_ptr</em> has broken copy semantics. The copies actually <em>moves</em> the <em>auto_ptr</em>, meaning it transfers the ownership on copy. As such, it&#8217;s unusable in standard containers and even deprecated by the C++11 standard.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on GotW #102: Exception-Safe Function Calls (Difficulty: 7/10) by GotW #102: Solution &#171; Sutter’s Mill</title>
		<link>http://herbsutter.com/gotw/_102/#comment-4690</link>
		<dc:creator><![CDATA[GotW #102: Solution &#171; Sutter’s Mill]]></dc:creator>
		<pubDate>Fri, 20 Jan 2012 20:42:39 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?page_id=1327#comment-4690</guid>
		<description><![CDATA[[...] The solution to GotW #102 is now live. Share this:EmailRedditTwitter [...]]]></description>
		<content:encoded><![CDATA[<p>[...] The solution to GotW #102 is now live. Share this:EmailRedditTwitter [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on C++11 &#8220;GoingNative 2012&#8221;: Speakers and Sessions by Rahul Singh</title>
		<link>http://herbsutter.com/2012/01/16/c11-goingnative-2012-speakers-and-sessions/#comment-4689</link>
		<dc:creator><![CDATA[Rahul Singh]]></dc:creator>
		<pubDate>Fri, 20 Jan 2012 08:36:58 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1322#comment-4689</guid>
		<description><![CDATA[Herb,

I would like to ask you the same question that Nikhil has asked but I will put it in a different way. The question is being Microsoft being so aggressive in 

1. Making the un-managed code perform faster on their platforms.
2. Making the performance of managed code better day by day.

Why should the developers use C++ instead of C#. Don&#039;t get me wrong as I am a big fan of C++ and worked with C++ for almost 6 years (recently shifted to C#). I also like what Microsoft is doing with performance optimization for managed code and the new platforms being able to run them in a better way. I am just curious because shifting from C++ to C# felt like &quot;Man, things became so easy now, i can finish up early and efficiently without worrying about dormant leaks and bugs in my code.&quot; and I presume many guys would have felt the same (Nikhil could confirm). so now I should pick up C++ for development on future versions of windows. 

I am saying this with no means of offending anyone (I see 2 rate downs in Nikhil&#039;s post), I am just curious whether I should ever be going back to the world of C++ or not.

Rahul]]></description>
		<content:encoded><![CDATA[<p>Herb,</p>
<p>I would like to ask you the same question that Nikhil has asked but I will put it in a different way. The question is being Microsoft being so aggressive in </p>
<p>1. Making the un-managed code perform faster on their platforms.<br />
2. Making the performance of managed code better day by day.</p>
<p>Why should the developers use C++ instead of C#. Don&#8217;t get me wrong as I am a big fan of C++ and worked with C++ for almost 6 years (recently shifted to C#). I also like what Microsoft is doing with performance optimization for managed code and the new platforms being able to run them in a better way. I am just curious because shifting from C++ to C# felt like &#8220;Man, things became so easy now, i can finish up early and efficiently without worrying about dormant leaks and bugs in my code.&#8221; and I presume many guys would have felt the same (Nikhil could confirm). so now I should pick up C++ for development on future versions of windows. </p>
<p>I am saying this with no means of offending anyone (I see 2 rate downs in Nikhil&#8217;s post), I am just curious whether I should ever be going back to the world of C++ or not.</p>
<p>Rahul</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on C++11 &#8220;GoingNative 2012&#8221;: Speakers and Sessions by Catherine</title>
		<link>http://herbsutter.com/2012/01/16/c11-goingnative-2012-speakers-and-sessions/#comment-4688</link>
		<dc:creator><![CDATA[Catherine]]></dc:creator>
		<pubDate>Thu, 19 Jan 2012 23:50:40 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1322#comment-4688</guid>
		<description><![CDATA[Looking forward. Nice panel.]]></description>
		<content:encoded><![CDATA[<p>Looking forward. Nice panel.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on C++11 &#8220;GoingNative 2012&#8221;: Speakers and Sessions by Nikhil Ramabhadra</title>
		<link>http://herbsutter.com/2012/01/16/c11-goingnative-2012-speakers-and-sessions/#comment-4687</link>
		<dc:creator><![CDATA[Nikhil Ramabhadra]]></dc:creator>
		<pubDate>Thu, 19 Jan 2012 19:54:02 +0000</pubDate>
		<guid isPermaLink="false">https://herbsutter.wordpress.com/?p=1322#comment-4687</guid>
		<description><![CDATA[Hi Herb,

 I am a developer and have coded in C++, VC++ MFC, Delphi, C#, ASP .NET MVC2. I have a question regarding C++ in Windows 8.

Why should developers or companies consider using C++ instead of C# or Html5, Javascript to develop Metro applications? It seems that it is quicker to develop in these languages than writing code in C++. The impression that I have gotten from the videos of the build conference is that the performance hit is not significant in case of  C# in Windows 8 as the .NET framework is not there or when using Html5, Javascript. It would be significant to use C++ only when one is writing games or high performance software. It seems like C++ has been killed in Windows 8!

Nikhil]]></description>
		<content:encoded><![CDATA[<p>Hi Herb,</p>
<p> I am a developer and have coded in C++, VC++ MFC, Delphi, C#, ASP .NET MVC2. I have a question regarding C++ in Windows 8.</p>
<p>Why should developers or companies consider using C++ instead of C# or Html5, Javascript to develop Metro applications? It seems that it is quicker to develop in these languages than writing code in C++. The impression that I have gotten from the videos of the build conference is that the performance hit is not significant in case of  C# in Windows 8 as the .NET framework is not there or when using Html5, Javascript. It would be significant to use C++ only when one is writing games or high performance software. It seems like C++ has been killed in Windows 8!</p>
<p>Nikhil</p>
]]></content:encoded>
	</item>
</channel>
</rss>
