<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Comment Feed for Channel 9 - Stephan T. Lavavej - Core C++, 7 of n</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n/RSS"></atom:link>
	<image>
		<url>http://media.ch9.ms/ch9/d1ce/949a6d45-7399-46cb-b82e-affaf38bd1ce/STLCCSeries7_220.jpg</url>
		<title>Channel 9 - Stephan T. Lavavej - Core C++, 7 of n</title>
		<link></link>
	</image>
	<description>In Part 7, STL teaches us about Usual Arithmetic Conversions, Template Metaprogramming, and shares some of the STL internal&amp;nbsp;implementation ( some of it not yet released  ). Many of you have asked for some treatment of TMP and STL delivers! Merry Christmas. Here&#39;s hoping you all have a wonderful 2013. &amp;nbsp; See part 1: Name LookupSee part 2: Template Argument DeductionSee part 3: Overload ResolutionSee part 4: Virtual FunctionsSee part 5: Explicit and Partial SpecializationSee part 6: New C&amp;#43;&amp;#43;11 features added to the Visual C&amp;#43;&amp;#43; 2012 compiler (CTP) </description>
	<link></link>
	<language>en</language>
	<pubDate>Sat, 18 May 2013 16:21:39 GMT</pubDate>
	<lastBuildDate>Sat, 18 May 2013 16:21:39 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[<p>And a very Happy Chridtmas to you too Stephan! Here's hoping we'll get to see a lot more of you on Chnnel 9 in 2013. Major kudos for all your efforts this year mate.</p><p>posted by tomkirbygreen</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634920669866374541</link>
		<pubDate>Tue, 25 Dec 2012 21:16:26 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634920669866374541</guid>
		<dc:creator>tomkirbygreen</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[<p>Happy Christmas to you Stephen,<br>Bring on more C&#43;&#43; videos.<br>Keep up the good work, an excellent&nbsp;Christmas&nbsp;present from C9 team.<br>Thanks again <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-2.gif?v=c9' alt='Big Smile' /></p><p>posted by Tominator2005</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634920801823553065</link>
		<pubDate>Wed, 26 Dec 2012 00:56:22 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634920801823553065</guid>
		<dc:creator>Tominator2005</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[<p><span id=".reactRoot[33].[1][2][1]{comment450872291638763_450981038294555}.0.[1].0.[1].0.[0].[0][2]"><span id=".reactRoot[33].[1][2][1]{comment450872291638763_450981038294555}.0.[1].0.[1].0.[0].[0][2].0" class="UFICommentBody"><span id=".reactRoot[33].[1][2][1]{comment450872291638763_450981038294555}.0.[1].0.[1].0.[0].[0][2].0.[2]">Thank you for all your work, Stephen! Merry Christmas &amp; Happy New Year! <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif?v=c9' alt='Smiley' /><br></span></span></span></p><p>posted by Matt_PD</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634920812022849256</link>
		<pubDate>Wed, 26 Dec 2012 01:13:22 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634920812022849256</guid>
		<dc:creator>Matt_PD</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[<p>Merry Christmas, great effort once again. Channel9 is&nbsp; my one stop destination to listen and watch this and all the other videos on C&#43;&#43;/STL/Haskell and so on and so forth. Thank you Mr. Stephan T. Lavavej, Charles and all the other nice people at Channel9.</p><p>posted by Aeon</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634921018866530989</link>
		<pubDate>Wed, 26 Dec 2012 06:58:06 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634921018866530989</guid>
		<dc:creator>Aeon</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[<p>Thank you Stephan and others. Merry Christmas and Happy new year.</p><p>posted by Spetum</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634921036902478295</link>
		<pubDate>Wed, 26 Dec 2012 07:28:10 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634921036902478295</guid>
		<dc:creator>Spetum</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[<p>Thank you Stephen, and Merry Christmas.</p><p>A great video as usual, and this time for a too often ignored subject that I care very much about.</p><p>Just to be sure I'm on the right path: in your example about the case of a &quot;-2 billion&quot; signed long to be added to a &quot;-7 billion&quot; signed long long (@ around 30:20 in the video), the conversion of the &quot;-2 billion&quot; should be to a LL not a ULL, right?</p><p>posted by abigagli</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634921143659788269</link>
		<pubDate>Wed, 26 Dec 2012 10:26:05 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634921143659788269</guid>
		<dc:creator>abigagli</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[<p>Thank you Stephan for all you brought to us.&nbsp;</p><p>Look forward to seeing you often on Channel9.&nbsp;</p><p>Merry Christmas and Happy New Year!&nbsp;</p><p>posted by yanshuai</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634921726415276294</link>
		<pubDate>Thu, 27 Dec 2012 02:37:21 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634921726415276294</guid>
		<dc:creator>yanshuai</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[Just wanted to join in the chorus. Thanks so much for all the hard work. I really enjoy these lectures. They taught me a lot about the core language and the Standard Template Library and Visual Studio&#39;s implementation there of. They gave me lots of insights I&#39;m really using in my day-to-day work. Stephan, you are my hero&#33;<br><br>So thanks Stephan, Charles, and the invisible team behind the camera.<br><p>posted by bkircher</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634922011285848106</link>
		<pubDate>Thu, 27 Dec 2012 10:32:08 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634922011285848106</guid>
		<dc:creator>bkircher</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[I would be of the opinion that a programmer trying to pass a value outside of a type&#39;s range deserves the spanking that the compiler would hand out.<br><br>Well it seems now at least the STL will give those &#40;us&#63;&#41; bad programmers a pass due to its use of template metaprogramming. Talking of which, I would like to see more lectures about&#47;including the arcane and mysterious world of template metaprogramming.<br><br>Keep up the awesome work&#33;<br>  <br><br><p>posted by Philhippus</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634922300098161475</link>
		<pubDate>Thu, 27 Dec 2012 18:33:29 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634922300098161475</guid>
		<dc:creator>Philhippus</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[<p>Thanks everyone!</p><p>abigagli&gt; in your example about the case of a &quot;-2 billion&quot; signed long to be added to a &quot;-7 billion&quot; signed long long (@ around 30:20 in the video), the conversion of the &quot;-2 billion&quot; should be to a LL not a ULL, right?</p><p>Argh, I simultaneously misspoke and scribbled the wrong thing on the whiteboard. (I might have been distracted by correcting myself from saying &quot;promoted&quot; to saying &quot;converted&quot; earlier.) You're absolutely correct - the signed long is widened to signed long long. I should have said &quot;signed long long&quot; and scribbled &quot;sll&quot; on the whiteboard at that moment. I correctly said &quot;value preserving&quot; and &quot;negative 9 billion&quot; immediately afterwards.</p><p>I apologize for the confusion, and thank you for the valuable correction.</p><p>Philhippus&gt; I would be of the opinion that a programmer trying to pass a value outside of a type's range deserves the spanking that the compiler would hand out. Well it seems now at least the STL will give those (us?) bad programmers a pass due to its use of template metaprogramming.</p><p>The Standard says that comparing a signed char to an unsigned long long must compile (although the compiler can warn about anything if it wants to). Similarly, passing a range of signed char and a value of unsigned long long to std::find() must compile.</p><p>I would characterize this as &quot;squirrelly&quot;, but the rules are the rules, and the STL has to follow them.</p><p>&gt; Talking of which, I would like to see more lectures about/including the arcane and mysterious world of template metaprogramming.</p><p>I'll look for more places to mention it. I really don't like presenting template metaprogramming in the absence of realistic context, because that makes it seem bizarre and pointless. find() is a great example because we have good reasons to do lots of template metaprogramming:</p><p>* We need to determine when the stars align for the memchr() optimization, which requires detecting when the iterator (after &quot;unwrapping&quot;) is a pointer to a possibly-const byte, and the value is integral.</p><p>* Then we need a 4-way test for all combinations of signed/unsigned ranges and signed/unsigned values.</p><p>* Plus a fifth case for when a small negative element could be equal to a huge unsigned value.</p><p>* Plus a special case for bool (mostly to avoid compiler warnings but also to avoid programmer headaches - there's enough going on here already).</p><p>posted by STL</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634922473723500473</link>
		<pubDate>Thu, 27 Dec 2012 23:22:52 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634922473723500473</guid>
		<dc:creator>STL</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[Excellent presentation, Thank you for all your efforts on Channel 9. <br><br>Hope you and everyone at Microsoft, and Channel 9, had a wonderful Christmas, and has a Happy New Year&#33;<br><br><p>posted by Johnaton</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634922589635392327</link>
		<pubDate>Fri, 28 Dec 2012 02:36:03 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634922589635392327</guid>
		<dc:creator>Johnaton</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[Hi STL, <br>very cool lecture&#33;&#33; thank you&#33; is there any approx info about STL update&#63; we want initializer lists&#33;&#33; &#58;&#41;<p>posted by Alex</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634923331364393059</link>
		<pubDate>Fri, 28 Dec 2012 23:12:16 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634923331364393059</guid>
		<dc:creator>Alex</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[Reminds me of my silly safe_cast answer on StackOverflow &#58;&#41; http&#58;&#47;&#47;stackoverflow.com&#47;a&#47;998982&#47;34509<p>posted by Johannes Schaub</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634923783969086454</link>
		<pubDate>Sat, 29 Dec 2012 11:46:36 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634923783969086454</guid>
		<dc:creator>Johannes Schaub</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[I understand why you have the fifth and sixth overloads, but is there a reason you didn&#39;t just define the first four as one function using std&#58;&#58;numeric_limits&#39; &#58;&#58;lowest and &#58;&#58;max&#63;<p>posted by soc</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634924826390789020</link>
		<pubDate>Sun, 30 Dec 2012 16:43:59 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634924826390789020</guid>
		<dc:creator>soc</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[I was recently interested in allocators while fighting the horribly outdated CRT that prevents you from using your own much faster allocator.<br><br>I discovered Mr Lavavej&#39;s mallocator.<br><br>I was going to update it when I discovered an old bug that I assumed would have been fixed in Visual Studio 2012.<br><br>Why haven&#39;t this bug been fixed yet&#63;&#33;<br>Is this what microsoft calls C&#43;&#43; Renaissance and GoingNative&#63;<br>Very disappointing. Makes me sad and angry to be lied to my face with false advertisement.<br><br>Why am I worried about a warning&#63;<br>Because the compiler could silently do the wrong thing in the background.<br><br>mallocator&#58;<br>http&#58;&#47;&#47;blogs.msdn.com&#47;b&#47;vcblog&#47;archive&#47;2008&#47;08&#47;28&#47;the-mallocator.aspx<br><br>The still-alive bug&#58;<br>C4100 &#47;&#47; unreferenced formal parameter<br><br>Caused by this code&#58;<br>template &#60;typename T&#62; void Mallocator&#60;T&#62;&#58;&#58;destroy&#40;T &#42; const p&#41; const &#123;<br>    p-&#62;&#126;T&#40;&#41;&#59;<br>&#125;<br><br>I checked STL allocator and in xmemory header they are disabling that warning there too.<br><br>I&#39;m asking this here because I assume Mr Lavavej would know the answer to this question.<br>To be honest the msdn forums are useless and a wast of time.<br><p>posted by Fredrik</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634929949267769636</link>
		<pubDate>Sat, 05 Jan 2013 15:02:06 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634929949267769636</guid>
		<dc:creator>Fredrik</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[Got very ugly with all the special treatment of the crappy c&#43;&#43; compiler from microsoft but here it is.<br><br>Tear it to pieces, please.<br><br>&#47;&#47; http&#58;&#47;&#47;blogs.msdn.com&#47;b&#47;vcblog&#47;archive&#47;2008&#47;08&#47;28&#47;the-mallocator.aspx<br><br>&#47;&#47; The following headers are required for all allocators.<br>&#35;include &#60;stddef.h&#62;  &#47;&#47; Required for size_t and ptrdiff_t<br>&#35;include &#60;new&#62;       &#47;&#47; Required for placement new and std&#58;&#58;bad_alloc<br>&#35;include &#60;stdexcept&#62; &#47;&#47; Required for std&#58;&#58;length_error<br><br>&#47;&#47; The following headers contain stuff that Mallocator uses.<br>&#35;include &#60;stdlib.h&#62;  &#47;&#47; For malloc&#40;&#41; and free&#40;&#41;<br>&#35;include &#60;iostream&#62;  &#47;&#47; For std&#58;&#58;cout<br>&#35;include &#60;ostream&#62;   &#47;&#47; For std&#58;&#58;endl<br><br>&#47;&#47; The following headers contain stuff that main&#40;&#41; uses.<br>&#35;include &#60;list&#62;      &#47;&#47; For std&#58;&#58;list<br>&#35;include &#60;memory&#62;    &#47;&#47; For std&#58;&#58;addressof<br><br>&#47;&#47; Visual Studio 2012<br>&#35;define INFERIOR_COMPILER_VER 1700511061 &#47;&#47; 17.00.51106.1<br><br>&#35;if _MSC_FULL_VER &#60;&#61; INFERIOR_COMPILER_VER<br>&#9;&#35;define NOEXCEPT<br>&#35;else<br>&#9;&#35;define NOEXCEPT noexcept<br>&#35;endif<br><br>template &#60;typename T&#62; class Mallocator&#59;<br><br>&#47;&#47; specialize for void&#58;<br>template &#60;&#62;<br>class Mallocator&#60;void&#62; &#123;<br>public&#58;<br>&#9;typedef void&#42; pointer&#59;<br>&#9;typedef const void&#42; const_pointer&#59;<br>&#9;&#47;&#47; reference-to-void members are impossible.<br>&#9;&#47;&#47;typedef void&#38; reference&#59;<br>&#9;&#47;&#47;typedef const void&#38; const_reference&#59;<br>&#9;typedef void value_type&#59;<br>&#9;typedef size_t size_type&#59;<br>&#9;typedef ptrdiff_t difference_type&#59;<br><br>&#9;template &#60;typename U&#62; struct rebind &#123;<br>&#9;&#9;typedef Mallocator&#60;U&#62; other&#59;<br>&#9;&#125;&#59;<br>&#125;&#59;<br><br>template &#60;typename T&#62;<br>class Mallocator &#123;<br>public&#58;<br>&#9;&#47;&#47; The following will be the same for virtually all allocators.<br>&#9;typedef T value_type&#59;<br>&#9;typedef T&#42; pointer&#59;<br>&#9;typedef const T&#42; const_pointer&#59;<br>&#9;typedef T&#38; reference&#59;<br>&#9;typedef const T&#38; const_reference&#59;<br>&#9;typedef size_t size_type&#59;<br>&#9;typedef ptrdiff_t difference_type&#59;<br><br>&#9;&#47;&#47; The following must be the same for all allocators.<br>&#9;template &#60;typename U&#62; struct rebind &#123;<br>&#9;&#9;typedef Mallocator&#60;U&#62; other&#59;<br>&#9;&#125;&#59;<br><br>&#9;&#47;&#47; Default constructor, copy constructor, rebinding constructor, and destructor.<br>&#9;&#47;&#47; Empty for stateless allocators.<br>&#9;Mallocator&#40;&#41; NOEXCEPT &#123; &#125;<br>&#9;Mallocator&#40;const Mallocator&#38;&#41; NOEXCEPT &#123; &#125;<br>&#9;template &#60;typename U&#62; Mallocator&#40;const Mallocator&#60;U&#62;&#38;&#41; NOEXCEPT &#123; &#125;<br>&#9;&#126;Mallocator&#40;&#41; &#123; &#125;<br><br>&#9;pointer address&#40;reference r&#41; const NOEXCEPT &#123;<br>&#9;&#9;return std&#58;&#58;addressof&#40;r&#41;&#59;<br>&#9;&#125;<br><br>&#9;const_pointer address&#40;const_reference r&#41; const NOEXCEPT &#123;<br>&#9;&#9;return std&#58;&#58;addressof&#40;r&#41;&#59;<br>&#9;&#125;<br><br>&#9;size_type max_size&#40;&#41; const NOEXCEPT &#123;<br>&#9;&#9;&#47;&#47; The following has been carefully written to be independent of<br>&#9;&#9;&#47;&#47; the definition of size_t and to avoid signed&#47;unsigned warnings.<br>&#9;&#9;return &#40;static_cast&#60;size_type&#62;&#40;0&#41; - static_cast&#60;size_type&#62;&#40;1&#41;&#41; &#47; sizeof&#40;T&#41;&#59;<br>&#9;&#125;<br><br>&#9;&#47;&#47; The following will be different for each allocator.<br>&#9;pointer allocate&#40;size_type n, Mallocator&#60;void&#62;&#58;&#58;const_pointer &#47;&#42;hint&#42;&#47; &#61; 0&#41; const &#123;<br>&#9;&#9;&#47;&#47; Mallocator prints a diagnostic message to demonstrate<br>&#9;&#9;&#47;&#47; what it&#39;s doing. Real allocators won&#39;t do this.<br>&#9;&#9;std&#58;&#58;cout &#60;&#60; &#34;Allocating &#34; &#60;&#60; n &#60;&#60; &#40;n &#61;&#61; 1 &#63; &#34; object&#34; &#58; &#34;objects&#34;&#41;<br>&#9;&#9;&#9;&#60;&#60; &#34; of size &#34; &#60;&#60; sizeof&#40;T&#41; &#60;&#60; &#34;.&#34; &#60;&#60; std&#58;&#58;endl&#59;<br><br>&#9;&#9;&#47;&#47; The return value of allocate&#40;0&#41; is unspecified.<br>&#9;&#9;&#47;&#47; Mallocator returns NULL in order to avoid depending<br>&#9;&#9;&#47;&#47; on malloc&#40;0&#41;&#39;s implementation-defined behavior<br>&#9;&#9;&#47;&#47; &#40;the implementation can define malloc&#40;0&#41; to return NULL,<br>&#9;&#9;&#47;&#47; in which case the bad_alloc check below would fire&#41;.<br>&#9;&#9;&#47;&#47; All allocators can return NULL in this case.<br>&#9;&#9;if &#40;n &#61;&#61; 0&#41; &#123;<br>&#9;&#9;&#9;return nullptr&#59;<br>&#9;&#9;&#125;<br><br>&#9;&#9;&#47;&#47; All allocators should contain an integer overflow check.<br>&#9;&#9;&#47;&#47; The Standardization Committee recommends that std&#58;&#58;length_error<br>&#9;&#9;&#47;&#47; be thrown in the case of integer overflow.<br>&#9;&#9;if &#40;n &#62; max_size&#40;&#41;&#41; &#123;<br>&#9;&#9;&#9;throw std&#58;&#58;length_error&#40;&#34;Mallocator&#60;T&#62;&#58;&#58;allocate&#40;&#41; - Integer overflow.&#34;&#41;&#59;<br>&#9;&#9;&#125;<br><br>&#9;&#9;&#47;&#47; Mallocator wraps malloc&#40;&#41;.<br>&#9;&#9;void&#42; const pv &#61; malloc&#40;n &#42; sizeof&#40;T&#41;&#41;&#59;<br><br>&#9;&#9;&#47;&#47; Allocators should throw std&#58;&#58;bad_alloc in the case of memory allocation failure.<br>&#9;&#9;if &#40;pv &#61;&#61; nullptr&#41; &#123;<br>&#9;&#9;&#9;throw std&#58;&#58;bad_alloc&#40;&#41;&#59;<br>&#9;&#9;&#125;<br><br>&#9;&#9;return static_cast&#60;pointer&#62;&#40;pv&#41;&#59;<br>&#9;&#125;<br><br>&#9;void deallocate&#40;pointer p, size_type n&#41; const &#123;<br>&#9;&#9;&#47;&#47; Mallocator prints a diagnostic message to demonstrate<br>&#9;&#9;&#47;&#47; what it&#39;s doing. Real allocators won&#39;t do this.<br>&#9;&#9;std&#58;&#58;cout &#60;&#60; &#34;Deallocating &#34; &#60;&#60; n &#60;&#60; &#40;n &#61;&#61; 1 &#63; &#34; object&#34; &#58; &#34;objects&#34;&#41;<br>&#9;&#9;&#9;&#60;&#60; &#34; of size &#34; &#60;&#60; sizeof&#40;T&#41; &#60;&#60; &#34;.&#34; &#60;&#60; std&#58;&#58;endl&#59;<br><br>&#9;&#9;&#47;&#47; Mallocator wraps free&#40;&#41;.<br>&#9;&#9;free&#40;p&#41;&#59;<br>&#9;&#125;<br><br>&#35;if _MSC_FULL_VER &#60;&#61; INFERIOR_COMPILER_VER<br>&#9;void construct&#40;pointer p&#41; const &#123;<br>&#9;&#9;void&#42; const pv &#61; static_cast&#60;void&#42; const&#62;&#40;p&#41;&#59;<br>&#9;&#9;&#58;&#58;new &#40;pv&#41; T&#40;&#41;&#59;<br>&#9;&#125;<br><br>&#9;void construct&#40;pointer p, const_reference t&#41; const &#123;<br>&#9;&#9;void&#42; const pv &#61; static_cast&#60;void&#42; const&#62;&#40;p&#41;&#59;<br>&#9;&#9;&#58;&#58;new &#40;pv&#41; T&#40;t&#41;&#59;<br>&#9;&#125;<br><br>&#9;void construct&#40;pointer p, value_type&#38;&#38; t&#41; const &#123;<br>&#9;&#9;void&#42; const pv &#61; static_cast&#60;void&#42; const&#62;&#40;p&#41;&#59;<br>&#9;&#9;&#58;&#58;new &#40;pv&#41; T&#40;std&#58;&#58;forward&#60;value_type&#62;&#40;t&#41;&#41;&#59; &#47;&#47; Still confused about move vs forward, not sure which one to use<br>&#9;&#125;<br><br>&#9;void destroy&#40;pointer p&#41; const&#59; &#47;&#47; Defined below.<br>&#35;else<br>&#9;template&#60;class U, class... Args&#62;<br>&#9;void construct&#40;U&#42; p, Args&#38;&#38;... args&#41; &#123;<br>&#9;&#9;void&#42; const pv &#61; static_cast&#60;void&#42; const&#62;&#40;p&#41;&#59;<br>&#9;&#9;&#58;&#58;new &#40;pv&#41; U&#40;std&#58;&#58;forward&#60;Args&#62;&#40;args&#41;...&#41;&#59;<br>&#9;&#125;<br><br>&#9;template &#60;class U&#62;<br>&#9;void destroy&#40;U&#42; p&#41; &#123;<br>&#9;&#9;p-&#62;&#126;U&#40;&#41;&#59;<br>&#9;&#125;<br>&#35;endif<br><br>&#9;&#47;&#47; Note&#58; The standard say these should be globals<br>&#9;&#47;&#47; not sure if it matter they are inside the class or not.<br><br>&#9;&#47;&#47; Returns true if and only if storage allocated from &#42;this<br>&#9;&#47;&#47; can be deallocated from other, and vice versa.<br>&#9;&#47;&#47; Always returns true for stateless allocators.<br>&#9;bool operator&#61;&#61;&#40;const Mallocator&#38; other&#41; const NOEXCEPT &#123;<br>&#9;&#9;return true&#59;<br>&#9;&#125;<br><br>&#9;bool operator&#33;&#61;&#40;const Mallocator&#38; other&#41; const NOEXCEPT &#123;<br>&#9;&#9;return &#33;&#40;&#42;this &#61;&#61; other&#41;&#59;<br>&#9;&#125;<br><br>&#9;&#47;&#47; Allocators are not required to be assignable, so<br>&#9;&#47;&#47; all allocators should have a private unimplemented<br>&#9;&#47;&#47; assignment operator. Note that this will trigger the<br>&#9;&#47;&#47; off-by-default &#40;enabled under &#47;Wall&#41; warning C4626<br>&#9;&#47;&#47; &#34;assignment operator could not be generated because a<br>&#9;&#47;&#47; base class assignment operator is inaccessible&#34; within<br>&#9;&#47;&#47; the STL headers, but that warning is useless.<br>private&#58;<br>&#9;Mallocator&#38; operator&#61;&#40;const Mallocator&#38;&#41;&#59;<br>&#125;&#59;<br><br>&#47;&#47; A compiler bug causes it to believe that p-&#62;&#126;T&#40;&#41; doesn&#39;t reference p.<br>&#47;&#47; Note&#58; Disabling a warning doesn&#39;t work inside a class which is why the function is here.<br>&#35;if _MSC_FULL_VER &#60;&#61; INFERIOR_COMPILER_VER<br>&#9;&#35;pragma warning&#40;push&#41;<br>&#9;&#35;pragma warning&#40;disable&#58; 4100&#41; &#47;&#47; unreferenced formal parameter<br>&#35;endif<br><br>&#47;&#47; The definition of destroy&#40;&#41; must be the same for all allocators.<br>template &#60;typename T&#62; void Mallocator&#60;T&#62;&#58;&#58;destroy&#40;pointer p&#41; const &#123;<br>&#9;p-&#62;&#126;T&#40;&#41;&#59;<br>&#125;<br><br>&#35;if _MSC_FULL_VER &#60;&#61; INFERIOR_COMPILER_VER<br>&#9;&#35;pragma warning&#40;pop&#41;<br>&#35;endif<br><br>int main&#40;&#41; &#123;<br>&#9;using namespace std&#59;<br><br>&#9;cout &#60;&#60; &#34;Constructing l&#58;&#34; &#60;&#60; endl&#59;<br><br>&#9;list&#60;int, Mallocator&#60;int&#62; &#62; l&#59;<br><br>&#9;cout &#60;&#60; endl &#60;&#60; &#34;l.push_back&#40;1729&#41;&#58;&#34; &#60;&#60; endl&#59;<br><br>&#9;l.push_back&#40;1729&#41;&#59;<br><br>&#9;cout &#60;&#60; endl &#60;&#60; &#34;l.push_back&#40;2161&#41;&#58;&#34; &#60;&#60; endl&#59;<br><br>&#9;l.push_back&#40;2161&#41;&#59;<br><br>&#9;cout &#60;&#60; endl&#59;<br><br>&#9;for &#40;auto i &#61; l.cbegin&#40;&#41;&#59; i &#33;&#61; l.cend&#40;&#41;&#59; &#43;&#43;i&#41; &#123;<br>&#9;&#9;cout &#60;&#60; &#34;Element&#58; &#34; &#60;&#60; &#42;i &#60;&#60; endl&#59;<br>&#9;&#125;<br><br>&#9;cout &#60;&#60; endl &#60;&#60; &#34;Destroying l&#58;&#34; &#60;&#60; endl&#59;<br>&#125;<br><br>&#47;&#42;<br>Using Visual Studio 2012 &#40;fully updated as of 2013-01-05&#41;<br><br>-&#62;Release x64&#58;<br>Constructing l&#58;<br>Allocating 1 object of size 24.<br><br>l.push_back&#40;1729&#41;&#58;<br>Allocating 1 object of size 24.<br><br>l.push_back&#40;2161&#41;&#58;<br>Allocating 1 object of size 24.<br><br>Element&#58; 1729<br>Element&#58; 2161<br><br>Destroying l&#58;<br>Deallocating 1 object of size 24.<br>Deallocating 1 object of size 24.<br>Deallocating 1 object of size 24.<br><br>-&#62;Debug x64&#58;<br>Constructing l&#58;<br>Allocating 1 object of size 24.<br>Allocating 1 object of size 16.<br><br>l.push_back&#40;1729&#41;&#58;<br>Allocating 1 object of size 24.<br><br>l.push_back&#40;2161&#41;&#58;<br>Allocating 1 object of size 24.<br><br>Element&#58; 1729<br>Element&#58; 2161<br><br>Destroying l&#58;<br>Deallocating 1 object of size 24.<br>Deallocating 1 object of size 24.<br>Deallocating 1 object of size 24.<br>Deallocating 1 object of size 16.<br>&#42;&#47;<br><p>posted by Fredrik</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634930094243570722</link>
		<pubDate>Sat, 05 Jan 2013 19:03:44 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634930094243570722</guid>
		<dc:creator>Fredrik</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[<p>Alex&gt; is there any approx info about STL update? we want initializer lists!! <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif?v=c9' alt='Smiley' /></p><p>I can't talk about release dates, sorry.</p><p>soc&gt; I understand why you have the fifth and sixth overloads, but is there a reason you didn't just define the first four as one function using std::numeric_limits' ::lowest and ::max?</p><p>We define find() in our internal header &lt;xutility&gt;, which is included by almost everything and doesn't drag in &lt;limits&gt;.</p><p>Fredrik&gt; Because the compiler could silently do the wrong thing in the background.</p><p>It's a spurious warning. It doesn't lead to silent bad codegen. Nowadays I'd just suppress it with a (void) cast. (I did report it to the compiler team.)</p><p>C&#43;&#43;11's minimal allocator interface doesn't require destroy() anymore, which is nice.</p><p>posted by STL</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634932132868991888</link>
		<pubDate>Tue, 08 Jan 2013 03:41:26 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634932132868991888</guid>
		<dc:creator>STL</dc:creator>
	</item>
	<item>
		<title>Re: Stephan T. Lavavej - Core C++, 7 of n</title>
		<description>
			<![CDATA[<p>Part 8: <a href="http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-Cpp-8-of-n">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-Cpp-8-of-n</a></p><p>posted by STL</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634956963378086265</link>
		<pubDate>Tue, 05 Feb 2013 21:25:37 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-7-of-n#c634956963378086265</guid>
		<dc:creator>STL</dc:creator>
	</item>
</channel>
</rss>