<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Ben Kuhn's Blog</title><subtitle type="html">Windows Printing, Open Packaging Conventions, XPS, and random bits of C++</subtitle><id>http://blogs.msdn.com/benkuhn/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/benkuhn/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2007-02-19T13:03:00Z</updated><entry><title>Article on Common Criteria (security) &amp; OPC </title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/archive/2009/11/10/article-on-common-criteria-security-opc.aspx" /><id>http://blogs.msdn.com/benkuhn/archive/2009/11/10/article-on-common-criteria-security-opc.aspx</id><published>2009-11-10T17:49:00Z</published><updated>2009-11-10T17:49:00Z</updated><content type="html">&lt;P&gt;There's a new Article out by Jack Davis on Common Criteria and the OPC. Common Criteria is an ISO standard used to&amp;nbsp;asses the security of IT products. This article shows how Common Criteria relate to OPC. Check it out.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/magazine/dd890995.aspx"&gt;http://msdn.microsoft.com/en-us/magazine/dd890995.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9920298" width="1" height="1"&gt;</content><author><name>benkuhn</name><uri>http://blogs.msdn.com/members/benkuhn.aspx</uri></author></entry><entry><title>OPC Team blog just went live.</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/archive/2009/05/18/opc-team-blog-just-went-live.aspx" /><id>http://blogs.msdn.com/benkuhn/archive/2009/05/18/opc-team-blog-just-went-live.aspx</id><published>2009-05-18T18:43:00Z</published><updated>2009-05-18T18:43:00Z</updated><content type="html">&lt;P&gt;Our PM just turned on the faucet on the team blog:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/opc/" mce_href="http://blogs.msdn.com/opc/"&gt;http://blogs.msdn.com/opc/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;This is the place to go for the latest on Microsoft efforts related to OPC. It's primarily run by the folks in Windows that work on OPC related tech, including myself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;- Ben&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9625438" width="1" height="1"&gt;</content><author><name>benkuhn</name><uri>http://blogs.msdn.com/members/benkuhn.aspx</uri></author><category term="OPC" scheme="http://blogs.msdn.com/benkuhn/archive/tags/OPC/default.aspx" /><category term="Windows" scheme="http://blogs.msdn.com/benkuhn/archive/tags/Windows/default.aspx" /></entry><entry><title>RC SDK is available, updated OPC documentation</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/archive/2009/05/18/rc-sdk-is-available-updated-opc-documentation.aspx" /><id>http://blogs.msdn.com/benkuhn/archive/2009/05/18/rc-sdk-is-available-updated-opc-documentation.aspx</id><published>2009-05-18T17:31:00Z</published><updated>2009-05-18T17:31:00Z</updated><content type="html">&lt;P&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt; mso-fareast-font-family: Calibri; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-theme-font: minor-latin"&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=6db1f17f-5f1e-4e54-a331-c32285cdde0c&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=6db1f17f-5f1e-4e54-a331-c32285cdde0c&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=6db1f17f-5f1e-4e54-a331-c32285cdde0c&amp;amp;displaylang=en&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt; mso-fareast-font-family: Calibri; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-theme-font: minor-latin"&gt;For those of you following my blog for PrintTicket, there's not much in the way of PrintTicket news in the latest SDK. On the OPC side, you'll see no major changes in functionality, though there are a few new error codes and the documentation is substantially expanded. We removed the OPC_STREAM_IO_READWRITE mode from CreateStreamOnFile, since that mode is a bit misleading in terms of intended, supported behavior. The OPC OM&amp;nbsp;APIs don't support an in-place edit model, and even writing back out to the same source data can be problematic with the OPC&amp;nbsp;OM becaue of delay loading. To see the complete set of changes for the OPC Object Model and digitial signature support for OPC, diff the RC version of msopc.idl against the beta version.&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9625359" width="1" height="1"&gt;</content><author><name>benkuhn</name><uri>http://blogs.msdn.com/members/benkuhn.aspx</uri></author><category term="OPC" scheme="http://blogs.msdn.com/benkuhn/archive/tags/OPC/default.aspx" /><category term="SDK" scheme="http://blogs.msdn.com/benkuhn/archive/tags/SDK/default.aspx" /><category term="Release Candidate" scheme="http://blogs.msdn.com/benkuhn/archive/tags/Release+Candidate/default.aspx" /><category term="Windows" scheme="http://blogs.msdn.com/benkuhn/archive/tags/Windows/default.aspx" /></entry><entry><title>WinDbg, lists, and hello world</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/archive/2009/03/18/windbg-lists-and-hello-world.aspx" /><id>http://blogs.msdn.com/benkuhn/archive/2009/03/18/windbg-lists-and-hello-world.aspx</id><published>2009-03-18T23:36:00Z</published><updated>2009-03-18T23:36:00Z</updated><content type="html">&lt;P&gt;Watching me use WinDbg is probably a bit like watching a new programmer write hello world in Visual Studio. I know I'm sitting in front of a very awesome, powerful, tool, and yet, I'm happy and get what I want out of a vocabulary of just a few commands. The problem is that I haven't made it past those few commands in years now. I finally decided today that I needed to figure a few more things out. In this case, I wanted to see a list, and I didn't feel like walking it by hand. For simple data types, something like dt -r 100 might work, but wasn't practical in this case. It was time to find out how to write a loop in a debugger command.&lt;/P&gt;
&lt;P&gt;To set things up, here's the struct I was looking at:&lt;/P&gt;
&lt;P&gt;struct link {&lt;BR&gt;&amp;nbsp; void *stuff;&lt;BR&gt;&amp;nbsp; link *pnext;&lt;BR&gt;};&lt;/P&gt;
&lt;P&gt;To get the whole list to dump, we need a couple of things. First, we need someplace to store the current link. For that, we can use user-defiend &lt;A target=_blank href="http://msdn.microsoft.com/en-us/library/cc266544.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc266544.aspx"&gt;psuedo-registers&lt;/A&gt;. User regsisters are $t0 to $t19. As the name implies, they're not real registers, and changing them has no effect on program execution. I used $t0, and initialized it to the address of the head of my list:&lt;/P&gt;
&lt;P&gt;r $t0 = 0x1234&lt;/P&gt;
&lt;P&gt;Next we need a loop. Since this is a list, a &lt;A href="http://msdn.microsoft.com/en-us/library/cc266565.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc266565.aspx"&gt;while loop &lt;/A&gt;seemed like a natural choice. Note that unlike C / C++, in debugger script, the '{' and '}' are required. In my first go at this, I wrote ".while (0 != $t0) {...}" and it was quite slow. It turns out that the debugger first does a symbol lookup on $t0, and sometimes can be confused and not treat $t0 properly in expressions. For this reason, it's good to be in the habit of writing &lt;A target=_blank href="http://msdn.microsoft.com/en-us/library/cc266540.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc266540.aspx"&gt;@&lt;/A&gt; in front of the register names. Sometimes it'll make things faster. Other times it will make things work. I don't think there's a way to lose by doing this. That gets us to a loop that looks like:&lt;/P&gt;
&lt;P&gt;.while (0 != @$t0) { ... }&lt;/P&gt;
&lt;P&gt;Now, what goes in the ellipses? First, we need to output what we have, then we need to increment our loop counter. Dumping the output is easy, that's what &lt;A target=_blank href="http://msdn.microsoft.com/en-us/library/cc266712.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc266712.aspx"&gt;dt&lt;/A&gt; was designed for. Don't forget the '@' in the register name!&lt;/P&gt;
&lt;P&gt;dt link @$t0&lt;/P&gt;
&lt;P&gt;We also need to update our register. Right now we have a pointer to the stuct. We need to get to the value of pNext. First, let's update our pointer to point to the location of pNext. That means we need the offset of the member. The debugger can give us this using &lt;A target=_blank href="http://msdn.microsoft.com/en-us/library/cc266712.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc266712.aspx"&gt;dt&lt;/A&gt;&amp;nbsp;again, and it's worth checking (not guessing) because the compiler can add padding. Just leave the address off the dt command and the debugger will dump the struct layout:&lt;/P&gt;
&lt;P&gt;dt link&lt;/P&gt;
&lt;P&gt;That shows us that the offset pNext pointer is at offset 0x8 (I'm debugging on x64). Putting together expressions in the debugger can feel a bit like a black art sometimes, but if you're familiar with just &lt;A target=_blank href="http://msdn.microsoft.com/en-us/library/cc266548.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc266548.aspx"&gt;poi&lt;/A&gt;, +, *, and -, you'll be able to get most things done that you need to. poi dereferences a value in an expression to a location in the target process memory, and the result is a pointer-sized value at the target location.&lt;/P&gt;
&lt;P&gt;r $t0 = poi(@$t0+8)&lt;/P&gt;
&lt;P&gt;Put it all together, and we get:&lt;/P&gt;
&lt;P&gt;r $t0 = 0x1234; .while (0 == @$t0) { r $t0; dt _link @$t0; r $t0 = poi(@$t0+8); }&lt;/P&gt;
&lt;P&gt;There's probably an even better way to do this. There almost always is in WinDbg. This got the job done for me though, and I've tucked this away on my blog in case I forget &amp;amp; need to find it again later.&lt;/P&gt;
&lt;P&gt;So, was this useful? If you found this useful, or want to see some other topic up here, leave a comment and let me know. Anything C++, debugging, printing, XPS, or OPC related is fair game right now.&lt;/P&gt;
&lt;P&gt;- Ben&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9488117" width="1" height="1"&gt;</content><author><name>benkuhn</name><uri>http://blogs.msdn.com/members/benkuhn.aspx</uri></author><category term="windbg" scheme="http://blogs.msdn.com/benkuhn/archive/tags/windbg/default.aspx" /><category term="debugging" scheme="http://blogs.msdn.com/benkuhn/archive/tags/debugging/default.aspx" /></entry><entry><title>OPC Forums on MSDN are now live.</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/archive/2009/02/10/opc-forums-on-msdn-are-now-live.aspx" /><id>http://blogs.msdn.com/benkuhn/archive/2009/02/10/opc-forums-on-msdn-are-now-live.aspx</id><published>2009-02-11T05:43:00Z</published><updated>2009-02-11T05:43:00Z</updated><content type="html">&lt;P&gt;Just a quick note: we've opened up a new forum on MSDN for questions and discussion about OPC. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://social.msdn.microsoft.com/Forums/en-US/os_opc/threads"&gt;http://social.msdn.microsoft.com/Forums/en-US/os_opc/threads&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Enjoy!&lt;/P&gt;
&lt;P&gt;Ben&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9411872" width="1" height="1"&gt;</content><author><name>benkuhn</name><uri>http://blogs.msdn.com/members/benkuhn.aspx</uri></author></entry><entry><title>Welcome to the XPS &amp; OPC APIs</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/archive/2008/11/25/xps-opc-apis-or-why-i-was-writing-c-stuff.aspx" /><id>http://blogs.msdn.com/benkuhn/archive/2008/11/25/xps-opc-apis-or-why-i-was-writing-c-stuff.aspx</id><published>2008-11-26T00:46:00Z</published><updated>2008-11-26T00:46:00Z</updated><content type="html">&lt;P&gt;My team has been heads down getting some great stuff together for all of you working on printing &amp;amp; beyond, so I haven't been writing as much lately. I haven't abandoned those of you who follow my blog for PrintTicket, though things in that space have been pretty quiet around here for the most part. If there's a topic you'd like to see more info on though, please do leave a comment or send me feedback.&lt;/P&gt;
&lt;P&gt;The big news though is that coming in Windows 7, and available with the &lt;A href="http://msdn.microsoft.com/en-us/evalcenter/dd353271.aspx" mce_href="http://msdn.microsoft.com/en-us/evalcenter/dd353271.aspx"&gt;beta&lt;/A&gt;, there are two new sets of APIs coming out in the upcoming Windows 7 SDK. First, we'll have support for &lt;A href="http://msdn.microsoft.com/en-us/library/dd316976(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd316976(VS.85).aspx"&gt;XPS document reading &amp;amp; creation&lt;/A&gt;. Second, we'll have a set of &lt;A href="http://msdn.microsoft.com/en-us/library/dd371623(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd371623(VS.85).aspx"&gt;APIs for creating OPC&lt;/A&gt; (Open Packaging Conventions) packages. Both APIs will support reading &amp;amp; writing of the corresponding file types, progressive loading, and COM interface surfaces. Additionally, we have support for &lt;A href="http://msdn.microsoft.com/en-us/library/dd372947(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd372947(VS.85).aspx"&gt;digital signatures for XPS&lt;/A&gt;, and the ability to create &lt;A href="http://msdn.microsoft.com/en-us/library/dd371626(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd371626(VS.85).aspx"&gt;digital signatures &amp;amp; policies for your own packages&lt;/A&gt; as well.&lt;/P&gt;
&lt;P&gt;Along with that news, I'd also like to point out that the Windows 7 SDK Beta has just been released, and is available &lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=a91dc12a-fc94-4027-b67e-46bab7c5226c&amp;amp;DisplayLang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=a91dc12a-fc94-4027-b67e-46bab7c5226c&amp;amp;DisplayLang=en"&gt;here&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;Getting started with the OPC APIs doesn't take much:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;1) Install the Beta. The OPC APIs only run on Windows 7&lt;/P&gt;
&lt;P&gt;2) Install the SDK. If you're using Visual Studio, you'll find a tool in the start menu after installing to update Visual Studio to use the new SDK as well.&lt;/P&gt;
&lt;P&gt;3) Create / open a C++ project&lt;/P&gt;
&lt;P&gt;4) Include Windows.h &amp;amp; msopc.h. &lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's it. you're ready to go!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;FYI, If you're interested in the XPS / OPC space, here's another blog that you should be watching:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/adrianford" mce_href="http://blogs.msdn.com/adrianford"&gt;http://blogs.msdn.com/adrianford&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;I'll be posting more about OPC, XPS&amp;nbsp;&amp;amp; the new APIs in the coming weeks, so stay tuned!&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;- Ben&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9142834" width="1" height="1"&gt;</content><author><name>benkuhn</name><uri>http://blogs.msdn.com/members/benkuhn.aspx</uri></author><category term="Windows 7" scheme="http://blogs.msdn.com/benkuhn/archive/tags/Windows+7/default.aspx" /><category term="Open Packaging Conventions" scheme="http://blogs.msdn.com/benkuhn/archive/tags/Open+Packaging+Conventions/default.aspx" /><category term="XML Paper Specification" scheme="http://blogs.msdn.com/benkuhn/archive/tags/XML+Paper+Specification/default.aspx" /><category term="OPC" scheme="http://blogs.msdn.com/benkuhn/archive/tags/OPC/default.aspx" /><category term="XPS" scheme="http://blogs.msdn.com/benkuhn/archive/tags/XPS/default.aspx" /><category term="beta" scheme="http://blogs.msdn.com/benkuhn/archive/tags/beta/default.aspx" /></entry><entry><title>more typelists &amp; templates</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/archive/2008/08/11/more-typelists-templates.aspx" /><id>http://blogs.msdn.com/benkuhn/archive/2008/08/11/more-typelists-templates.aspx</id><published>2008-08-12T02:46:00Z</published><updated>2008-08-12T02:46:00Z</updated><content type="html">&lt;P&gt;My co-worker Aaron was quick to reply to my earlier post on templates in type-lists with this alternative:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Calibri size=3&gt;You instead add a non-templated function invoker object:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;struct&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt; factory_invoker&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;template&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt; &amp;lt;&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;class&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt; a, &lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;class&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt; b&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;struct&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt; apply&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;typedef&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt; &lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;typedef&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt; factory&amp;lt;a,b&amp;gt;::type type;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;}&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;}&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Then your typelist has normal types in the list, but those types happen to be template metafunctions.&amp;nbsp; To invoke one of these that is in a typelist:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;I&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: green; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;// assuming tlist1 is a typelist&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;typename&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt; tlist1::head::&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;template&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt; apply&amp;lt;&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;int&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;, &lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;char&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 'Courier New'; mso-highlight: white"&gt;&amp;gt;::type&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;(the above ‘template’ and ‘typename’ keywords are, as always, only required or even allowd when used inside a template)&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Which in this case will end up naming the type ‘MyType&amp;lt;int, char&amp;gt;’ for you.&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This also works. However in my case since I was trying to reduce the number of generated types, so I stuck with the previous solution.&lt;/P&gt;
&lt;P&gt;Thanks Aaron!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8849502" width="1" height="1"&gt;</content><author><name>benkuhn</name><uri>http://blogs.msdn.com/members/benkuhn.aspx</uri></author></entry><entry><title>random bits of Windows-related stuff</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/archive/2008/07/24/random-bits-of-windows-related-stuff.aspx" /><id>http://blogs.msdn.com/benkuhn/archive/2008/07/24/random-bits-of-windows-related-stuff.aspx</id><published>2008-07-24T20:45:00Z</published><updated>2008-07-24T20:45:00Z</updated><content type="html">&lt;P&gt;[Mohave] Microsoft's 'new' operating system is apparently doing well at wow-ing customers. This sounds fun, and I'm looking forward to seeing how this story develops. &lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: Calibri; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;A href="http://news.cnet.com/8301-13860_3-9998336-56.html?tag=nefd.lede"&gt;http://news.cnet.com/8301-13860_3-9998336-56.html?tag=nefd.lede&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;[crash dumps] Ben Martens has a good point &lt;A class="" href="http://blogs.msdn.com/ben/archive/2008/07/24/we-want-your-crash-dump.aspx" mce_href="http://blogs.msdn.com/ben/archive/2008/07/24/we-want-your-crash-dump.aspx"&gt;here&lt;/A&gt;: send your crash dumps, we care! We don't necessarily look at every one, one by one, but in aggregate, we rely on them as one way of understanding your pain when things go boink. If you don't tell us, we don't know.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8769714" width="1" height="1"&gt;</content><author><name>benkuhn</name><uri>http://blogs.msdn.com/members/benkuhn.aspx</uri></author></entry><entry><title>fun with templates: part two - type factories</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/archive/2008/07/23/fun-with-templates-part-two-type-factories.aspx" /><id>http://blogs.msdn.com/benkuhn/archive/2008/07/23/fun-with-templates-part-two-type-factories.aspx</id><published>2008-07-23T20:56:00Z</published><updated>2008-07-23T20:56:00Z</updated><content type="html">&lt;P&gt;Scenario: &lt;/P&gt;
&lt;P&gt;I have a template that takes a significant number of arguments, but in the most common use scenarios, there are some constraints that can be applied. I want to make it easier for clients to use the templates in the most common cases.&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;template&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; &amp;lt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;typename&lt;/SPAN&gt;&lt;FONT color=#000000&gt; command_base_t, &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;typename&lt;/SPAN&gt;&lt;FONT color=#000000&gt; thread_policy_t,&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;typename&lt;/SPAN&gt;&lt;FONT color=#000000&gt; completion_policy_t,&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt;&amp;gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; CommandQueue&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt;};&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; ExecOnThreadPool;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; ExecSingleThreaded;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;FONT color=#000000&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; SyncronousCompletion;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; AsyncCompletion;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;Now, 99% of all of our usage is for either sync or async threadpool or single threaded command queues. I want to minimize the surface area used in common use cases to make it easier to modify the base template in the future. &lt;/P&gt;
&lt;P mce_keep="true"&gt;Solution:&lt;/P&gt;
&lt;P mce_keep="true"&gt;We can default the recusion policy, but that still requires the caller to be aware of all of the type names, order of parameters, etc. It also means that if we want to add some parameters later or tweak the class in some non-trivial way, we have to touch all of the client code. We can abstract a lot of this by creating templates that take just the thing that changes frequently, and abstracts away the actual template parameters.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;template&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &amp;lt;&lt;SPAN style="COLOR: blue"&gt;typename&lt;/SPAN&gt; command_base_t&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;struct&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; CommandQueueFactory&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;typedef&lt;/SPAN&gt; CommandQueue&amp;lt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;command_base_t, &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ExecOnThreadPool, &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;SyncronousCompletion, &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;gt; SyncronousQueue;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;typedef&lt;/SPAN&gt; CommandQueue&amp;lt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;command_base_t, &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ExecOnThreadPool, &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;AsyncCompletion, &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;gt; AsyncronousQueue;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;};&lt;/SPAN&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;With this in place, most clients would use the template via the typedefs:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;CommandQueueFactory&amp;lt;CommandBase&amp;gt;::SyncronousQueue myQueue;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;CommandQueueFactory&amp;lt;CommandBase&amp;gt;::AsyncQueue myAsyncQueue;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Now most client code doesn't have a dependency on the specific policies or template parameter ordering of the original template class. When you need to go back and change the base template, you have far less code to touch to add a new parameter. Type factories are also useful in some scenarios involving template metaprogramming. Most notably, they can be used in typelists and traits classes to act as unspecifed template in metaprogramming constructs (I'll post more on this later).&lt;/P&gt;
&lt;P mce_keep="true"&gt;[Special thanks to Tom M. for introducing me to this technique.&amp;nbsp;As far as I can tell, he was the first to discover this trick.]&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8767496" width="1" height="1"&gt;</content><author><name>benkuhn</name><uri>http://blogs.msdn.com/members/benkuhn.aspx</uri></author><category term="C++" scheme="http://blogs.msdn.com/benkuhn/archive/tags/C_2B002B00_/default.aspx" /><category term="type factory" scheme="http://blogs.msdn.com/benkuhn/archive/tags/type+factory/default.aspx" /><category term="metaprogramming" scheme="http://blogs.msdn.com/benkuhn/archive/tags/metaprogramming/default.aspx" /><category term="templates" scheme="http://blogs.msdn.com/benkuhn/archive/tags/templates/default.aspx" /></entry><entry><title>Fun with templates, part one - abstracting operations:</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/archive/2008/07/22/fun-with-templates-part-one.aspx" /><id>http://blogs.msdn.com/benkuhn/archive/2008/07/22/fun-with-templates-part-one.aspx</id><published>2008-07-23T07:58:00Z</published><updated>2008-07-23T07:58:00Z</updated><content type="html">&lt;P&gt;[edited 7-23-08: updated title, tags]&lt;/P&gt;
&lt;P&gt;I'm planning a talk on template use, and thought my blog might be a good way to gether my thoughts, and also to share some of the concepts that I've been working with. Over the next few days (or maybe weeks) I'll try to post a number of articles dealing with a variety of ways to get more mileage out of templates &amp;amp; related techniques. Tonight I want to show how to make even the&amp;nbsp; simplest templates a bit more flexible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Consider the following: you want to write a storage class that operates on a class T, but over the years, you've acquired a few different smart pointer libraries, and you need to replace the value in the pointer. You're smart pointer libraries all use different semantics though:&lt;/P&gt;
&lt;P&gt;1) sp::replace(spObject, pValue)&lt;/P&gt;
&lt;P&gt;2) pObject.Reset(pValue)&lt;/P&gt;
&lt;P&gt;3) pObject&amp;nbsp;= pValue&lt;/P&gt;
&lt;P&gt;Now, without making a value judgement on which I prefer, how do you write a template that can work with all three types? One solution is to create a library of overloaded functions that we can use in our template to perform operations&amp;nbsp;on the types that might be smart pointers.&amp;nbsp;To handle the assign case above, we can use this:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;namespace&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; sp_ops&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;template&lt;/SPAN&gt; &amp;lt;&lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; assign( spa&amp;lt;T&amp;gt; &amp;amp; pointer, &lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; T &amp;amp; value)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pointer.reset(value);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;template&lt;/SPAN&gt; &amp;lt;&lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; assign(spb&amp;lt;T&amp;gt; &amp;amp; pointer, &lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; T &amp;amp; value)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;spb&amp;lt;T&amp;gt;::reset(pointer, value);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;template&lt;/SPAN&gt; &amp;lt;&lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; dest_t, &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; assign( dest_t &amp;amp; target, &lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; T &amp;amp; value)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;target = value;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;};&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;The overloads for assign allow us to use a consistent semantic for assign in our template implementation regardless of which smart pointer is used as a template argument. This is a bit like a policy, but unlike a policy, we pre-configure the possible policies, and don't require the usr of the template to supply the correct policy for their pointer. Also, note taht by using two template parameters on the last variation, we create a catch-all. Anything that supports assignment, and isn't one of the two template types falls into the last bucket. Here's how this actually plays out in the template that we wanted to write in the first place:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;template&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &amp;lt;&lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; storage_t, &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; value_t&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; canister&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;public&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; set( &lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; value_t &amp;amp; value ) &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;sp_ops::assign(contents, value);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;storage_t contents;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;};&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Could we have just written overloads for set? Not really, because the type that we wanted to change behavior on is a class template parameter, not a function parameter. Finally, it's worth noting that container is a very incomplete, rough class. It's just enough code to show the usage. As an interesting excercise, it's also worth noting that you can use this to handle diverse parameters as well. For example:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;template&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &amp;lt;&lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; storage_t, &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; value_t&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; canister&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;public&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;template&lt;/SPAN&gt; &amp;lt;&lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; T&amp;gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;assign_to( T &amp;amp; target )&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;sp_ops::assign(target, contents);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;storage_t contents;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P&gt;With this last variation, we can now assign out to anything that supports assignment semantics. To really support the last scenario, we may need to define versions of assign that define some transfer semantics for our intrusively ref counted objects, and of course there's not much we can do for transferring objects managed by shared pointers from one library to another. Assuming that the smart pointers are assignable to pointers of the same type though, and not implicitly convertable to bare pointers (this is almost always a bad idea, quite dangerous) this will cover the valid caess. If one of your smart pointers can implicitly convert to a bare pointer, you may want to create a prototype for the assign from that smart pointer to the other smart pointer types, but not give it a body. This prevents accidentally creating two owners for the same object. Any attempt to do so will result in use of an undefined function. A compile time assert in the function would also provide a meaningful check (I won't cover compile time asserts here. They are well documented elsewhere). &lt;/P&gt;
&lt;P&gt;Well, that's enough fun for one night. I'll try to post again soon. If you have suggestions for topics related to templates, feel free to send suggestions via my feedback link. Note that for the time being, I'm going to try to avoid some of the heavier topics around template metaprogramming (I have some ideas queued up, but those need to wait until I get through some more basics!)&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Ben&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8765984" width="1" height="1"&gt;</content><author><name>benkuhn</name><uri>http://blogs.msdn.com/members/benkuhn.aspx</uri></author><category term="C++" scheme="http://blogs.msdn.com/benkuhn/archive/tags/C_2B002B00_/default.aspx" /><category term="metaprogramming" scheme="http://blogs.msdn.com/benkuhn/archive/tags/metaprogramming/default.aspx" /><category term="templates" scheme="http://blogs.msdn.com/benkuhn/archive/tags/templates/default.aspx" /><category term="abstraction" scheme="http://blogs.msdn.com/benkuhn/archive/tags/abstraction/default.aspx" /></entry><entry><title>template metaprogramming: type lists of templates</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/archive/2008/07/19/template-metaprogramming-type-lists-of-templates.aspx" /><id>http://blogs.msdn.com/benkuhn/archive/2008/07/19/template-metaprogramming-type-lists-of-templates.aspx</id><published>2008-07-19T10:00:00Z</published><updated>2008-07-19T10:00:00Z</updated><content type="html">&lt;P&gt;Ok, I said in an earlier post that I wasn't going to cover metaprogramming, but I have to post just this one.. it's a bit of a useful technique, and I&amp;nbsp;haven't seen it described anywhere else. I've been playing around with template metaprogramming in my spare time, and I ran accross an interesting C++ metaprogramming solution for a certain problem that, as far as I can tell, is rather novel. The issue that I had was that for various reasons, I wanted to store unspecified templates in a typelist (meaning that I wanted to use them as a template parameter so that I could specialize the types later). However, the&amp;nbsp;classic&amp;nbsp;type list uses typedefs, and you can't put an un-specialized template into a typedef. The way I got around this problem is to use a type factory. The type factory is a templatized class that declares a typedef of a concrete type using the type factor's template parameters:&lt;/P&gt;&lt;CODE&gt;
&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;template&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; a, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; b&amp;gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;struct&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; factory {&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; typedef&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; MyType&amp;lt;a, b&amp;gt; result;&lt;/P&gt;
&lt;P&gt;};&lt;/P&gt;&lt;/CODE&gt;
&lt;P&gt;To put these into a typelist, then, we just create a custom typelist that takes a template template parameter, and defines head as a type factory for the template template parameter type:&lt;/P&gt;&lt;CODE&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;template&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &amp;lt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; template&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; t_head, &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; typename&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; next&lt;/P&gt;
&lt;P&gt;&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;class&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; t2_typelist&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;:&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; template&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; a, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; b&amp;gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; struct&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; head_factory {&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; typedef&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; t_head&amp;lt;a, b&amp;gt; result;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; };&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; typedef&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; next tail;&lt;/P&gt;
&lt;P&gt;};&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/CODE&gt;
&lt;P&gt;It takes a lot of structure to create, but the practical upshot of it is that it seems to do a pretty good job of breaking up exponential expansions of type names in certain scenarios. One other downside which you may have noticed is that you have to create variations for templates that take different numbers of arguments. On the other hand, once you've done that, you can create a list that contain factories for&amp;nbsp;templates that use different numbers of template parameters.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8753769" width="1" height="1"&gt;</content><author><name>benkuhn</name><uri>http://blogs.msdn.com/members/benkuhn.aspx</uri></author></entry><entry><title>XPS Essentials Pack available for download</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/archive/2007/05/22/xps-essentials-pack-available-for-download.aspx" /><id>http://blogs.msdn.com/benkuhn/archive/2007/05/22/xps-essentials-pack-available-for-download.aspx</id><published>2007-05-22T20:33:00Z</published><updated>2007-05-22T20:33:00Z</updated><content type="html">&lt;P&gt;This is a bit older news now, but still, it's pretty awesome. The XPS Essentials Pack is now available for download from &lt;A href="http://www.microsoft.com/xps/" target=_new rel=nofollow&gt;&lt;FONT color=#0000cc&gt;http://www.microsoft.com/xps/&lt;/FONT&gt;&lt;/A&gt;. Among other things installing it on XP gets you an XPS viewer &amp;amp; the Microsoft XPS Document Writer, a print queue that allows you to convert any document you can print into XPS format.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2796953" width="1" height="1"&gt;</content><author><name>benkuhn</name><uri>http://blogs.msdn.com/members/benkuhn.aspx</uri></author></entry><entry><title>Print Schema 1.0 Specification is available</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/archive/2007/05/22/print-schema-1-0-specification-is-available.aspx" /><id>http://blogs.msdn.com/benkuhn/archive/2007/05/22/print-schema-1-0-specification-is-available.aspx</id><published>2007-05-22T20:16:00Z</published><updated>2007-05-22T20:16:00Z</updated><content type="html">&lt;P&gt;We've released the final version of Print Schema, and it can be downloaded from here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.microsoft.com/whdc/xps/printschema.mspx"&gt;&lt;FONT face=Calibri color=#0000cc size=3&gt;http://www.microsoft.com/whdc/xps/printschema.mspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Thanks everyone for the great feedback.&lt;/P&gt;
&lt;P&gt;Ben&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2796805" width="1" height="1"&gt;</content><author><name>benkuhn</name><uri>http://blogs.msdn.com/members/benkuhn.aspx</uri></author></entry><entry><title>PrintTicket Providers, CreateDC and CreateCompatibleDC</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/archive/2007/03/23/printticket-providers-createdc-and-createcompatibledc.aspx" /><id>http://blogs.msdn.com/benkuhn/archive/2007/03/23/printticket-providers-createdc-and-createcompatibledc.aspx</id><published>2007-03-23T20:36:00Z</published><updated>2007-03-23T20:36:00Z</updated><content type="html">&lt;P&gt;When developing PrintTicket support in&amp;nbsp;the configuration module of a filter-pipeline driver, you should be aware that your driver's PrintTicket code paths will be called within the SplWoW64.exe process when converting GDI content to XPS from 32-bit applications&amp;nbsp;running under 64-bit Vista. As a result, this article applies to the implementation of PrintTicket provider methods within the driver:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/aa505681.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/aa505681.aspx"&gt;&lt;FONT color=#0000ff&gt;http://msdn2.microsoft.com/en-us/library/aa505681.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;These limitations apply only to drivers in which the rendering module calls PrintTicket APIs, such as filter pipeline drivers. If your rendering module does not call PrintTicket APIs, this artical doesn't apply. With a few limited exceptions, PrintTicket APIs should not be called from GDI-based printer driver rendering modules.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1938598" width="1" height="1"&gt;</content><author><name>benkuhn</name><uri>http://blogs.msdn.com/members/benkuhn.aspx</uri></author></entry><entry><title>Print Schema 0.95 is available for download</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/benkuhn/archive/2007/02/19/print-schema-0-95.aspx" /><id>http://blogs.msdn.com/benkuhn/archive/2007/02/19/print-schema-0-95.aspx</id><published>2007-02-20T00:03:00Z</published><updated>2007-02-20T00:03:00Z</updated><content type="html">&lt;P&gt;The Print Schema 0.95 specification is finally live &amp;amp; ready for review:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://www.microsoft.com/whdc/xps/printschema.mspx"&gt;&lt;FONT face=Calibri size=3&gt;http://www.microsoft.com/whdc/xps/printschema.mspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;As mentioned in my previous post, we're not trying to change anything with this version of the documentation, but we do clarify a lot of things, and there's a lot more detail. So now, we'd love to get your feedback. If you do have comments or concerns about anything in the documentation, let us know at &lt;A href="mailto:prninfo@microsoft.com" mce_href="mailto:prninfo@microsoft.com"&gt;prninfo@microsoft.com&lt;/A&gt;. We'll take feedback for approximately a month. We haven't set a firm cutoff date yet, but I'll share it with you as soon as I know when it is.&lt;/P&gt;
&lt;P&gt;As far as suggestions go, generally speaking, we will not add new keywords, remove keywords, or change the structure of the document. However, we can clarify wording, broaden or narrrow the scope of a definition or add missing material.&lt;/P&gt;
&lt;P&gt;The next release will be the 1.0 final version so this will be the only chance to provide comments for this version of the specification.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1718650" width="1" height="1"&gt;</content><author><name>benkuhn</name><uri>http://blogs.msdn.com/members/benkuhn.aspx</uri></author></entry></feed>