<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Marius Bancila's Blog &#187; VS2010</title>
	<atom:link href="http://mariusbancila.ro/blog/tag/vs2010/feed/" rel="self" type="application/rss+xml" />
	<link>http://mariusbancila.ro/blog</link>
	<description>Sharing my opinions and ideas!</description>
	<lastBuildDate>Mon, 14 Nov 2011 07:19:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Things I like about native development with C++/CX</title>
		<link>http://mariusbancila.ro/blog/2011/11/12/things-i-like-about-native-development-with-ccx/</link>
		<comments>http://mariusbancila.ro/blog/2011/11/12/things-i-like-about-native-development-with-ccx/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 22:06:21 +0000</pubDate>
		<dc:creator>Marius Bancila</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[CTPs & Betas]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WinRT]]></category>
		<category><![CDATA[namespace]]></category>
		<category><![CDATA[partial classes]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[VisualStudio]]></category>
		<category><![CDATA[VS10]]></category>
		<category><![CDATA[VS11]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://mariusbancila.ro/blog/?p=1182</guid>
		<description><![CDATA[Visual Studio 11 brings many new things for native development, including support for new features from C++11 (unfortunately not all), or ability to write Metro apps with C++/CX including modeling the UI with XAML. In this post I will talk a bit about three favorite features that I noticed immediately after trying VS11 from Windows [...]]]></description>
			<content:encoded><![CDATA[<p>Visual Studio 11 brings many new things for native development, including support for new features from C++11 (unfortunately not all), or ability to write Metro apps with C++/CX including modeling the UI with XAML. In this post I will talk a bit about three favorite features that I noticed immediately after trying VS11 from Windows 8 Developer Preview.</p>
<p><strong>Use of namespaces</strong><br />
Finally, I see namespaces promoted in native code. Yes, it&#8217;s C++/CX and they were probably forced to use namespaces for a consistent experience from the various languages that target the Windows Runtime, but it&#8217;s a very nice change to the default templates for C++ projects where everything is put in the global namespace. I can only hope they will improve that in this version or the next for standard C++ applications (whether Win32 console apps or MFC apps).</p>
<pre class="cpp" name="code">
namespace Sample
{
    public ref class MainPage
    {
        public:
            MainPage();
            ~MainPage();
    };
}
</pre>
<p><strong>UPDATE</strong>: looks like I wasn&#8217;t clear enough, I&#8217;m not saying namespaces is a new C++ feature (duh), I&#8217;m saying Visual Studio templates for C++ don&#8217;t promote that. Create a Win32 project, an MFC project, and ATL project, there are no namespaces. You&#8217;d have to code everything manually, but if you do it, you mess the wizards. So, what I&#8217;m saying is that I hope we can see namespaces <u>promoted</u> for other project and item templates too.</p>
<p><strong>Partial classes</strong><br />
I <a href="http://mariusbancila.ro/blog/2011/10/13/cpp-winrt-and-partial-classes/">already wrote about partial classes</a>, but I want to reiterate this feature. Partial classes gives you the ability to define a class in several files. This is great because developers and code generator tools such as designers can edit different parts of the same class without interfering one with the other. This feature made it possible for supporting XAML user interfaces in C++/CX Metro applications.</p>
<p>I&#8217;m actually wondering why isn&#8217;t this already part of standard C++ and I can only wish that the next version (which hopefully will not take another decade to conclude) will include this feature.</p>
<p><strong>Better Syntax Highlighting</strong><br />
Below is a comparison for the same piece of code highlighted by Visual Studio 2010 on the left, and Visual Studio.vNext (11) on the right.<br />
<a href="/blog/wp-content/uploads/2011/11/vs10syntaxhighlight.png"><img alt="" src="/blog/wp-content/uploads/2011/11/vs10syntaxhighlight.png" title="Highlighting with VS10" class="alignnone" width="400" /></a><a href="/blog/wp-content/uploads/2011/11/vs11syntaxhighlight.png"><img alt="" src="/blog/wp-content/uploads/2011/11/vs11syntaxhighlight.png" title="Highlighting with VS11" class="alignnone" width="400" /></a><br />
There is hardly any formatting in VS10. However, on the other hand, the highlighting in VS11 is beautiful. User defined types (including library types) are displayed with another color than the built-in types (such as int), including in their definition. STL types (string, vector, etc.) are finally identified as types and displayed with the appropriate color. Also the name of parameters is displayed in italics which makes them easily identifiable. There are other things about the highlighting, but these striking changes.</p>
]]></content:encoded>
			<wfw:commentRss>http://mariusbancila.ro/blog/2011/11/12/things-i-like-about-native-development-with-ccx/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The Day Visual Studio Went Crazy</title>
		<link>http://mariusbancila.ro/blog/2011/05/06/the-day-visual-studio-went-crazy/</link>
		<comments>http://mariusbancila.ro/blog/2011/05/06/the-day-visual-studio-went-crazy/#comments</comments>
		<pubDate>Fri, 06 May 2011 21:17:20 +0000</pubDate>
		<dc:creator>Marius Bancila</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[installer]]></category>
		<category><![CDATA[SDK]]></category>
		<category><![CDATA[SP1]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://mariusbancila.ro/blog/?p=945</guid>
		<description><![CDATA[I said it before, the Visual Studio installer gets me mad. All is fine until you want to install the Service Pack. After that you cannot install additional components until you uninstall the SP. Because of that, you should make sure you installed the entire Visual Studio package before installing SP1. So I did, but [...]]]></description>
			<content:encoded><![CDATA[<p>I said it before, the Visual Studio installer gets me mad. All is fine until you want to install the Service Pack. After that you cannot install additional components until you uninstall the SP. Because of that, you should make sure you installed the entire Visual Studio package before installing SP1. So I did, but it proved not enough. Here is the story of what happened today.</p>
<ol>
<li>I installed Visual Studio 2010 Ultimate on my machine (a couple of weeks ago).</li>
<li>I installed Visual Studio 2010 SP1. So far all was good, I was able to use it with no problems.</li>
<li>But then I decided to install the Windows Phone developer tools, following the steps described on this <a href="http://create.msdn.com/en-us/home/getting_started">page</a>. After that, when I started Visual Studio 2010 I got this message that SP1 was applied only partially and in order to start the application it must be applied to all components (which was weird because I did that before a couple of times and everything was fine).
</li>
<li>I have installed the SP1 again. Then, when I started VS2010 it worked.</li>
<li>However, I wanted to install the <a href="http://archive.msdn.microsoft.com/vsvmsdk">Visual Studio Visualization and Modeling SDK</a> to be able to automatically build my text templates when building the solutions, as described <a href="http://mariusbancila.ro/blog/2011/05/04/generate-output-from-t4-at-build-time/">here</a>. This SDK needed <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=47305cf4-2bea-43c0-91cd-1b853602dcc5&#038;displaylang=en">Visual Studio 2010 SDK</a> installed on the machine. But when I ran the installer for the SDK I got the following error:
<p><img alt="" src="/blog/wp-content/uploads/2011/05/vs2010sdkerror.png" title="VS2010 SDK Error" class="alignnone" width="505" height="458" /></p>
<p>Obviously the error message was non-sense, not only I had VS2010 installed, but it had all the components, and the service pack was applied. Knowing the problems with the service pack, I immediately figured it was the reason.</li>
<li>I have uninstalled the Visual Studio 2010 SP1. Of course, while it was uninstalling it crashed, so I had to start it again.
<p><img alt="" src="/blog/wp-content/uploads/2011/05/vs2010sp1uninstallerror.png" title="VS2010 SP1 uninstall error" class="alignnone" width="667" height="652" /></li>
<li>I started the Visual Studio 2010 installer just to make sure I had all the components installed. However, I ran into this error:
<p><img alt="" src="/blog/wp-content/uploads/2011/05/vs2010setuperror.png" title="VS2010 setup error" class="alignnone" width="479" height="174" /></p>
<p>After several failed attempts I decided to restart Windows. That did the trick and the installer started correctly and I could make sure all the components were there.</li>
<li>I installed Visual Studio 2010 SDK successfully.</li>
<li>I installed Visual Studio Visualization and Modeling SDK successfully.</li>
<li>I installed Visual Studio 2010 SP1 successfully.</li>
</ol>
<p>Then, three hours later, I could start working with Visual Studio 2010 again. Text templates are automatically built, and the Windows Phone tools are working correctly.</p>
<p>Puff!</p>
]]></content:encoded>
			<wfw:commentRss>http://mariusbancila.ro/blog/2011/05/06/the-day-visual-studio-went-crazy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Generate Output from T4 at Build Time</title>
		<link>http://mariusbancila.ro/blog/2011/05/04/generate-output-from-t4-at-build-time/</link>
		<comments>http://mariusbancila.ro/blog/2011/05/04/generate-output-from-t4-at-build-time/#comments</comments>
		<pubDate>Wed, 04 May 2011 07:27:40 +0000</pubDate>
		<dc:creator>Marius Bancila</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[T4]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://mariusbancila.ro/blog/?p=922</guid>
		<description><![CDATA[Text templates (aka T4) is a great feature in Visual Studio, that proves helpful in many scenarios. I use it for instance in developing Alchemy. However, it has a significant drawback: it does not generate code automatically when you build your solution. To build the files and generate their output you have to manually run [...]]]></description>
			<content:encoded><![CDATA[<p>Text templates (aka T4) is a great feature in Visual Studio, that proves helpful in many scenarios. I use it for instance in developing <a href="http://mariusbancila.ro/blog/games/alchemy/">Alchemy</a>. However, it has a significant drawback: it does not generate code automatically when you build your solution. To build the files and generate their output you have to manually run either <strong>Run Custom Tool</strong> command for each .tt file, or <strong>Transform All Templates</strong> for the entire solution.</p>
<table border="0">
<tr valign="top">
<td><div class="wp-caption alignnone" style="width: 255px"><img alt="" src="/blog/wp-content/uploads/2011/05/vs2010runcustomtool.png" title="Run Custom Tool" width="245" height="214" /><p class="wp-caption-text">Run Custom Tool</p></div></td>
<td><div class="wp-caption alignnone" style="width: 292px"><img alt="" src="/blog/wp-content/uploads/2011/05/vs2010tat.png" title="Transform All Templates" width="282" height="107" /><p class="wp-caption-text">Transform All Templates</p></div></td>
</tr>
</table>
<p>The good news is that Visual Studio 2010 has added capabilities for building the text templates files automatically at the build time. Basically, what you have to do is two things: first install the <a href="http://archive.msdn.microsoft.com/vsvmsdk">Visual Studio Visualization and Modeling SDK</a>. Second, manually add the following to the project file:</p>
<pre name="code" class="xml">
   &lt;PropertyGroup>
      &lt;TransformOnBuild >true&lt;/TransformOnBuild>
   &lt;/PropertyGroup>

   &lt;Import Project=
     "$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TextTemplating\v10.0\Microsoft.TextTemplating.targets" />
</pre>
<p>And that should do the trick. When you build the project, the .tt files will also be built.</p>
<p>To read more about this topic see:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/ee847423.aspx">Code Generation in a Build Process</a></li>
<li><a href="http://www.olegsych.com/2010/04/understanding-t4-msbuild-integration/">Understanding T4: MSBuild Integration</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mariusbancila.ro/blog/2011/05/04/generate-output-from-t4-at-build-time/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>VS2010 Productivity Power Tools</title>
		<link>http://mariusbancila.ro/blog/2011/03/18/vs2010-productivity-power-tools/</link>
		<comments>http://mariusbancila.ro/blog/2011/03/18/vs2010-productivity-power-tools/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 14:23:49 +0000</pubDate>
		<dc:creator>Marius Bancila</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[addin]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://mariusbancila.ro/blog/?p=887</guid>
		<description><![CDATA[Productivity Power Tools is a Visual Studio 2010 add-in, developed by the Microsoft Visual Studio Platform Team and available in Visual Studio Gallery. Of course, you can also download it using Visual Studio Extension Manager, from the Tools menu in Visual Studio 2010. Its list of features is detailed on the add-in page and I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef">Productivity Power Tools</a> is a Visual Studio 2010 add-in, developed by the <a href="http://visualstudiogallery.msdn.microsoft.com/site/profile?userName=Microsoft%20-%20Visual%20Studio%20Platform%20Team">Microsoft Visual Studio Platform Team</a> and available in Visual Studio Gallery. Of course, you can also download it using Visual Studio Extension Manager, from the Tools menu in Visual Studio 2010.</p>
<p><img alt="" src="/blog/wp-content/uploads/2011/03/ppt_install.png" title="Extension Manager" class="alignnone" width="859" height="499" /></p>
<p>Its list of features is detailed on the add-in page and I will not enumerate them here. I just want to list the features that I find most useful (at least so far). All these features are enabled by default, but the add-in is very customizable. To enable/disable features or change current settings use the Options dialog and go the Productivity Power Tools page.</p>
<p><img alt="" src="/blog/wp-content/uploads/2011/03/ppt_options.png" title="Add-in Options" class="alignnone" width="747" height="430" /></p>
<p><strong>Highlight Current Line</strong><br />
The line where your cursor is displayed is highlighted so that you can easily spot it. Here is a screen shot.<br />
<img alt="" src="/blog/wp-content/uploads/2011/03/ppt_selection.png" title="Highlight Current Line" class="alignnone" width="647" height="160" /></p>
<p><strong>Go to Definition</strong><br />
If you press the Ctrl key while the cursor is over a symbol, the symbol appears as a hyperlink and clicking it will take you to the definition.<br />
<img alt="" src="/blog/wp-content/uploads/2011/03/ppt_gotodef.png" title="Click + Ctrl" class="alignnone" width="730" height="148" /></p>
<p><strong>Move Lines</strong><br />
You can move the current line or an entire selection up with Atl + Up Arrow, or down with Atl + Down Arrow. Useful to avoid Ctrl + X and Ctrl + V, unless you have to move too many lines up or down.<br />
<img alt="" src="/blog/wp-content/uploads/2011/03/ppt_moveline.png" title="Move Line" class="alignnone" width="664" height="159" /></p>
<p><strong>Modified Document Mark</strong><br />
Modified, but yet not saved documents, are indicated with a red dot on the tab.<br />
<img alt="" src="/blog/wp-content/uploads/2011/03/ppt_tabmodified.png" title="Modified Document" class="alignnone" width="302" height="30" /></p>
<p><strong>Pinned Tabs</strong><br />
You can pin tabs on the tab bar. When you hover the cursor over a tab, a pin indicator appears. You can click it and then the tab is pinned on the tab bar, from left to right, so that no mater how many documents you open, the pinned tabs remain visible and you are able to quickly access them.<br />
<img alt="" src="/blog/wp-content/uploads/2011/03/ppt_pin.png" title="Pinned Tabs" class="alignnone" width="556" height="174" /></p>
<p><strong>Undo Close</strong><br />
Recently closed documents are listed in a new tool window called Undo Close. You can double click them and they will be re-opened (and removed from the undo close list).<br />
<img alt="" src="/blog/wp-content/uploads/2011/03/ppt_undoclose.png" title="Undo Close" class="alignnone" width="675" height="291" /></p>
<p><strong>Floating Tabs</strong><br />
Many developers use two monitors (or even more). Now it is possible to dock floating tabs on a second monitor just as you&#8217;d do with a tool window. The following screen shot shows two tabs docked into a separate window on a second monitor.<br />
<img alt="" src="/blog/wp-content/uploads/2011/03/ppt_secondmonitor.png" title="Floating Tabs" class="alignnone" width="717" height="473" /></p>
<p><strong>Solution Navigator</strong><br />
A brand new solution explorer has been created allowing you to easily navigate the solution. You can search it, filter it to see only opened, unsaved, edited or all files, view related information about classes and members, preview images, etc. </p>
<p>The following image shows: the entire solution (left), only the items that contain the word <em>thumb</em> (middle) and only the opened items shown within their projects (right).<br />
<img alt="" src="/blog/wp-content/uploads/2011/03/ppt_solutionnavigator.png" title="Solution Navigator" class="alignnone" width="867" height="655" /></p>
<p>Another cool feature is the image preview. All you have to do is hover the cursor over an image and you get a preview of it, as shown below.<br />
<img alt="" src="/blog/wp-content/uploads/2011/03/ppt_previewimage.png" title="Preview Image" class="alignnone" width="282" height="508" /></p>
<p>Looking forward to seeing these features by default in Visual Studio and not available through an add-in.</p>
]]></content:encoded>
			<wfw:commentRss>http://mariusbancila.ro/blog/2011/03/18/vs2010-productivity-power-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resources for the F# Presentation at Ronua Roadshow</title>
		<link>http://mariusbancila.ro/blog/2010/07/18/resources-for-the-f-presentation-at-ronua-roadshow/</link>
		<comments>http://mariusbancila.ro/blog/2010/07/18/resources-for-the-f-presentation-at-ronua-roadshow/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 08:51:49 +0000</pubDate>
		<dc:creator>Marius Bancila</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[functional]]></category>
		<category><![CDATA[ronua]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://mariusbancila.ro/blog/?p=641</guid>
		<description><![CDATA[For those that attended my last evening presentation about F# at Ronua Roadshow in Timisoara (but not only), here is the demo I&#8217;ve shown, and one that I planned to show but didn&#8217;t due to lack of time. The purpose of these demos was to shown simple Windows Forms applications written in F#. Mandelbrot Fractal [...]]]></description>
			<content:encoded><![CDATA[<p>For those that attended my last evening presentation about F# at Ronua Roadshow in Timisoara (but not only), here is the demo I&#8217;ve shown, and one that I planned to show but didn&#8217;t due to lack of time. The purpose of these demos was to shown simple Windows Forms applications written in F#.</p>
<p><strong>Mandelbrot Fractal</strong><br />
A Mandelbrot set is a set of points in the complex plane, whose boundary forms a fractal. The fractal, known as Mandelbrot fractal, is obtain by associating a color with each point in the complex plane (or rather a subset of it). The color is chosen based on the result of computing the value of the complex quadratic polynomial Z(n+1) = Z(n)^2 + c for a number of iterations (100, 200, etc.). You can read more about it on <a href="http://en.wikipedia.org/wiki/Mandelbrot_set">Wikipedia</a>.</p>
<p>The program that I shown exhibits traits of both functional (for computing the fractal) and object oriented (for displaying the fractal) paradigms. It is a variation of the program available <a href="http://secretgeek.net/fsharp_mandelbrot2.asp">here</a>, for which I kept the functional part (computing the Mandelbrot set is not very fast, I must warn you), but redone the user interface part. You can use the mouse to drag the fractal and the wheel to zoom in and out.</p>
<p><img alt="" src="/blog/wp-content/uploads/2010/07/fsharp_mandelbrot.png" title="Mandelbrot fractal" class="alignnone" width="600" height="414" /></p>
<p>You can download it from <a href="http://www.mariusbancila.ro/blog/wp-content/uploads/2010/07/mandelbrot.zip">here</a>.</p>
<p><strong>Game of Life</strong><br />
I <a href="http://mariusbancila.ro/blog/2008/05/08/game-of-life-in-f/">blogged</a> about this two years ago, when F# was still far from a final release. In the meantime, syntax has changed, classes have changed, so if you try to run that implementation of mine you&#8217;ll run into some errors. I have updated the code to run correctly with Visual Studio 2010.</p>
<p><img alt="" src="/blog/wp-content/uploads/2010/07/fsharp_gameoflife.png" title="Game of Life" class="alignnone" width="641" height="483" /></p>
<p>You can download it from <a href="http://www.mariusbancila.ro/blog/wp-content/uploads/2010/07/mandelbrot.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mariusbancila.ro/blog/2010/07/18/resources-for-the-f-presentation-at-ronua-roadshow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VSBuildStatusAddin with Auto Show and Auto Hide</title>
		<link>http://mariusbancila.ro/blog/2010/06/02/vsbuildstatusaddin-with-auto-show-and-auto-hide/</link>
		<comments>http://mariusbancila.ro/blog/2010/06/02/vsbuildstatusaddin-with-auto-show-and-auto-hide/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 14:29:24 +0000</pubDate>
		<dc:creator>Marius Bancila</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[addin]]></category>
		<category><![CDATA[VS2005]]></category>
		<category><![CDATA[VS2008]]></category>
		<category><![CDATA[VS2010]]></category>
		<category><![CDATA[VSBuildStatus]]></category>

		<guid isPermaLink="false">http://mariusbancila.ro/blog/?p=557</guid>
		<description><![CDATA[A new version (1.3) of VSBuildStatus add-in for Visual Studio 2005, 2008 and 2010 is available. It allows you to configure the add-in window to automatically show up when a build/clean/deploy process starts, and/or automatically close when the operation ends. To enable the automatic show of the add-in window when a build/clean/deploy operation starts, check [...]]]></description>
			<content:encoded><![CDATA[<p>A new version (1.3) of <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/2A2293B4-1808-44AA-B030-661F6803D8A1">VSBuildStatus</a> add-in for Visual Studio 2005, 2008 and 2010 is available. It allows you to configure the add-in window to automatically show up when a build/clean/deploy process starts, and/or automatically close when the operation ends. </p>
<p><img alt="" src="/blog/wp-content/uploads/2010/06/VSBuildStatusAddin1.png" title="Addin window" class="alignnone" width="786" height="375" /></p>
<ul>
<li>To enable the automatic show of the add-in window when a build/clean/deploy operation starts, check <strong>Pop-out automatically when starting a build</strong></li>
<li>To enable the automatic hiding of the add-in window when the build/clean/deploy operation ends, check <strong>Auto hide when the build ends</strong>
<ul>
<li>you can set a delay interval for the hiding, varing from 0 to 300 seconds; if the delay is 0, the window is hidden immediatelly after the build ends</li>
<li>to keep the window shown when error(s) occurred during the build/clean/deploy operation, check <strong>DO NOT auto hide when an error occurs</strong></li>
</ul>
</li>
</ul>
<p>Here is a screen short of the properties window. It opens from the Settings button.</p>
<p><img alt="" src="/blog/wp-content/uploads/2010/06/VSBuildStatusAddin3.png" title="Properties window" class="alignnone" width="300" height="300" /></p>
<p>The add-in is available on the <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/2A2293B4-1808-44AA-B030-661F6803D8A1">Visual Studio Gallery</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mariusbancila.ro/blog/2010/06/02/vsbuildstatusaddin-with-auto-show-and-auto-hide/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2010</title>
		<link>http://mariusbancila.ro/blog/2010/04/12/visual-studio-2010/</link>
		<comments>http://mariusbancila.ro/blog/2010/04/12/visual-studio-2010/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 19:23:00 +0000</pubDate>
		<dc:creator>Marius Bancila</dc:creator>
				<category><![CDATA[Releases]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://mariusbancila.ro/blog/?p=526</guid>
		<description><![CDATA[Today Microsoft release officially Visual Studio 2010 and .NET Framework 4.0, with five major release events and many others across the globe. You can download it from MSDN. Those that don&#8217;t have an MSDN subscription can try the evaluation versions available here. Express editions are still available for free and can be downloaded from here. [...]]]></description>
			<content:encoded><![CDATA[<p>Today Microsoft release officially Visual Studio 2010 and .NET Framework 4.0, with five major release events and many others across the globe. You can download it from MSDN. Those that don&#8217;t have an MSDN subscription can try the evaluation versions available <a href="http://www.microsoft.com/visualstudio/en-us/download">here</a>. Express editions are still available for free and can be downloaded from <a href="http://www.microsoft.com/express/Windows/">here</a>.</p>
<p>During past months I have wrote various posts about the changes and new features for Visual C++. A summary of these articles are available <a href="http://mariusbancila.ro/blog/2010/04/02/visual-studio-2010-changes-for-vc-summary/">here</a>.</p>
<p>An important change in Visual Studio 2010 is that F#, now at version 2.0, is bundled in the IDE, just as the other languages, C++, C# and VB.NET. After 7 years in development it had become a first class language with today&#8217;s release.</p>
<p>More information about the release can be found here:<br />
<a href="http://blogs.msdn.com/somasegar/archive/2010/04/11/announcing-visual-studio-2010-and-net-framework-4.aspx">http://blogs.msdn.com/somasegar/archive/2010/04/11/announcing-visual-studio-2010-and-net-framework-4.aspx</a><br />
<a href="http://blogs.msdn.com/dsyme/archive/2010/04/12/f-2-0-released-as-part-of-visual-studio-2010.aspx">http://blogs.msdn.com/dsyme/archive/2010/04/12/f-2-0-released-as-part-of-visual-studio-2010.aspx</a><br />
<a href="http://blogs.msdn.com/jasonz/archive/2010/04/12/ship-it-visual-studio-2010-net-framework-4-now-available.aspx">http://blogs.msdn.com/jasonz/archive/2010/04/12/ship-it-visual-studio-2010-net-framework-4-now-available.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mariusbancila.ro/blog/2010/04/12/visual-studio-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2010 changes for VC++ (part 5)</title>
		<link>http://mariusbancila.ro/blog/2010/03/24/visual-studio-2010-changes-for-vc-part-5/</link>
		<comments>http://mariusbancila.ro/blog/2010/03/24/visual-studio-2010-changes-for-vc-part-5/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 21:10:48 +0000</pubDate>
		<dc:creator>Marius Bancila</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[VC++]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://mariusbancila.ro/blog/?p=501</guid>
		<description><![CDATA[I this post I will talk about the deployment changes in VC++ 2010. When you deploy an application to another machine you have to install not only the application but all the libraries that it depends on. When you build with VC++, you have dependencies on CRT (C/C++ runtime) and possible on MFC and/or ATL. [...]]]></description>
			<content:encoded><![CDATA[<p>I this post I will talk about the deployment changes in VC++ 2010. When you deploy an application to another machine you have to install not only the application but all the libraries that it depends on. When you build with VC++, you have dependencies on CRT (C/C++ runtime) and possible on MFC and/or ATL.</p>
<p>Visual Studio 2005 introduced a new deployment model for Windows client applications based on <em>isolated applications</em> and <em>side-by-side assemblies</em>. Assemblies can be either <strong>shared</strong> (globally registered in the system, installed in the Global Assembly Cache – GAC folder in Windows – and available to all applications) or <strong>side-by-side</strong> (described with a manifest, distributed with the application and available only to that application).</p>
<p>In Visual C++ 2005, library assemblies (such as MFC, ATL, CRT) have been rebuilt as <em>shared side-by-side</em> assemblies and installed in the native assembly cache, WinSxS folder in Windows. That means they are not globally registered in the system, but are globally available to the applications that specify a dependency with a manifest file.</p>
<p>With VC++ 2005 or 2008 there are several options for deployment:</p>
<ul>
<li><strong>static linking</strong>: when you link your application statically against VC++ libraries (CRT, MFC or ATL) the application doesn&#8217;t have any dependencies so you don&#8217;t have to deploy any other VC++ DLLs to the target machine</li>
<li><strong>shared side-by-side assemblies</strong>: the VC++ DLLs are deployed in the WinSxS folder; this can be done either with the Visual C++ Redistributable Merge Modules or the Visual C++ Redistributable Package; the application requires a manifest file that describes the dependent DLLs and their version</li>
<li><strong>private assemblies</strong>: the VC++ DLLs are all installed in the same folder with the application; the application requires a manifest file</li>
</ul>
<p>When you deploy an application built with Visual Studio 2005 or 2008 a manifest file that describes the dependencies, whether you deployed these VC++ DLLs in the local folder or they where installed in the WinSxS folder. If the manifest is missing you get an error. The next image shows the error received when running an MFC application (called Wordpad2008) build with VC++ 2008 on another machine without a manifest. </p>
<p><img alt="" src="/blog/wp-content/uploads/2010/03/vs2010deplymentwordpad2008.png" title="VC++ 2008 application without a manifest" class="alignnone" width="741" height="379" /></p>
<p>Though the purpose of this change was to simplify deployment, the result was probably the opposite. As a result Microsoft changed deployment requirements in Visual C++ 2010. You can now deploy applications without a Fusion or satellite manifest. All you need to do is copy the VC++ dependent DLLs to the application folder and run. The next image shows an MFC application (called Wordpad2010) built with VC++ 2010 running on another machine, without a satellite assembly. No error occurs any more when trying to start the application, because local deployment no longer require a satellite manifest.</p>
<p><img alt="" src="/blog/wp-content/uploads/2010/03/vs2010deplymentwordpad2010.png" title="VC++ 2010 application without a manifest" class="alignnone" width="741" height="411" /></p>
<p>With VC++ 2010 there are several options for deployment:</p>
<ul>
<li><strong>static linking</strong>: same as earlier</li>
<li><strong>central deployment</strong>: the VC++ DLLs are deployed in the system32 folder; this is useful for updates, because Windows automatically identifies and updates the DLLs that are deployed here</li>
<li><strong>local deployment</strong>: the application executable and its dependent DLLs are all installed in the same folder; no manifest file is required.</li>
</ul>
<p>To find more information about deployment and manifest files I suggest these links:</p>
<ul>
<li><a href="http://www.codeguru.com/forum/showthread.php?t=408061">Visual C++ Application: How to use manifests and re-distributable assemblies?</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms235316.aspx">Choosing a Deployment Method (VC++ 2008)</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/dd293574%28VS.100%29.aspx">Deployment in Visual C++ 2010</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms235342.aspx">Troubleshooting C/C++ Isolated Applications and Side-by-side Assemblies</a></li>
<li><a href="http://www.grimes.demon.co.uk/workshops/fusWSThirteen.htm">.NET Fusion</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mariusbancila.ro/blog/2010/03/24/visual-studio-2010-changes-for-vc-part-5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2010 changes for VC++ (part 4)</title>
		<link>http://mariusbancila.ro/blog/2010/03/23/visual-studio-2010-changes-for-vc-part-4/</link>
		<comments>http://mariusbancila.ro/blog/2010/03/23/visual-studio-2010-changes-for-vc-part-4/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 08:08:11 +0000</pubDate>
		<dc:creator>Marius Bancila</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[MFC]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[ribbon]]></category>
		<category><![CDATA[VC++]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://mariusbancila.ro/blog/?p=498</guid>
		<description><![CDATA[VC++ Feature Pack that came with Visual Studio 2008 SP1 introduced support for the Office Fluent Ribbon. However, developers had to create ribbons entirely from code, because there was no support in the resource editor for that. Visual Studio 2010 comes with a visual designer for the ribbon. You can choose whether to use a [...]]]></description>
			<content:encoded><![CDATA[<p>VC++ Feature Pack that came with Visual Studio 2008 SP1 introduced support for the Office Fluent Ribbon. However, developers had to create ribbons entirely from code, because there was no support in the resource editor for that. Visual Studio 2010 comes with a visual designer for the ribbon.</p>
<p>You can choose whether to use a ribbon or a classical menu and toolbar when you create an application.</p>
<p><img alt="" src="/blog/wp-content/uploads/2010/03/ribbonnew.png" title="Use a ribbon instead of menu and toolbar" class="alignnone" width="627" height="532" /></p>
<p>By default, the created ribbon has one category (Home) and two panels with several commands.</p>
<p><img alt="" src="/blog/wp-content/uploads/2010/03/ribbondefault.png" title="Default ribbon" class="alignnone" width="365" height="180" /></p>
<p>The ribbon can be opened from the resource editor. There is a new category called Ribbon. By default the ribbon resource is called IDR_RIBBON. The description of the ribbon is kept in an XML file called <strong>ribbon.mfcribbon-ms</strong>, located in the res folder.</p>
<p><img alt="" src="/blog/wp-content/uploads/2010/03/ribbonresources.png" title="Ribbon in resource editor" class="alignnone" width="316" height="241" /></p>
<p>When the ribbon is opened, the toolbar displays controls that can be dragged and drop into the ribbon, including categories, context categories, panels, and a series of controls such as buttons, checkbox, edits, progress bar, slider, etc.</p>
<p><img alt="" src="/blog/wp-content/uploads/2010/03/ribbontoolbar.png" title="Ribbon toolbar" class="alignnone" width="301" height="516" /></p>
<p>There is support for several styles, Office like and Windows 7. These different styles can be seen in the following image.</p>
<p><img alt="" src="/blog/wp-content/uploads/2010/03/ribbonstyles.png" title="Ribbon styles" class="alignnone" width="521" height="733" /></p>
<p>The designer provides support for quick testing of the ribbon. On the Ribbon Editor toolbar there is a button called Test Ribbon that opens window with the ribbon. You can quickly see how it will look in the application, however, the commands are not available; clicking on the ribbon commands does not have any effect.</p>
<p><img alt="" src="/blog/wp-content/uploads/2010/03/ribbontestbutton.png" title="Ribbon designer test button" class="alignnone" width="369" height="210" /></p>
<p><img alt="" src="/blog/wp-content/uploads/2010/03/ribbontestlive.png" title="Ribbon live test" class="alignnone" width="521" height="400" /></p>
<p>You can add handlers for the ribbon commands just like you do for a menu or a toolbar. In Visual Studio 2010 this can be done with the class wizard.</p>
<p><img alt="" src="/blog/wp-content/uploads/2010/03/ribbonhandlers.png" title="Ribbon command handlers" class="alignnone" width="783" height="407" /></p>
<p>You can read more about the ribbon designed in <a href="http://msdn.microsoft.com/en-us/library/bb386089%28VS.100%29.aspx" target="_blank">MSDN</a> or the <a href="http://blogs.msdn.com/vcblog/archive/2009/10/01/ribbon-designer.aspx" target="_blank">VC++ Team&#8217;s Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mariusbancila.ro/blog/2010/03/23/visual-studio-2010-changes-for-vc-part-4/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2010 changes for VC++ (part 3)</title>
		<link>http://mariusbancila.ro/blog/2010/03/22/visual-studio-2010-changes-for-vc-part-3/</link>
		<comments>http://mariusbancila.ro/blog/2010/03/22/visual-studio-2010-changes-for-vc-part-3/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 08:36:23 +0000</pubDate>
		<dc:creator>Marius Bancila</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[auto]]></category>
		<category><![CDATA[decltype]]></category>
		<category><![CDATA[lambda]]></category>
		<category><![CDATA[static_assert]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://mariusbancila.ro/blog/?p=491</guid>
		<description><![CDATA[Some of the important changs in Visual Studio 2010 in regard to VC++ are represented by the support in the C++ compiler of some of the features already approved for the new C++ standard, so far called C++0x. In this post I will give a short overview on then. static_assert I already wrote a post [...]]]></description>
			<content:encoded><![CDATA[<p>Some of the important changs in Visual Studio 2010 in regard to VC++ are represented by the support in the C++ compiler of some of the features already approved for the new C++ standard, so far called C++0x. In this post I will give a short overview on then.</p>
<p><strong>static_assert</strong></p>
<p>I already <a href="http://mariusbancila.ro/blog/2009/02/25/c-static_assert-a-niche-feature/">wrote a post</a> about this feature. At that time I considered it rather a niche feature. However, this looks much powerful in conjunction with the <a href="http://msdn.microsoft.com/en-us/library/bb982077.aspx">type traits classes</a> from TR1.</p>
<p>static_assert checks if an expression is true at compile time. If the expression if false a custom error message is displayed and the compilation fails. If the expression is true the declaration has no effect.</p>
<p>In the following example I create a comparison template function, that is used later to compare values.</p>
<pre name="code" class="cpp">
template < typename T >
bool CompareNumbers(T v1, T v2)
{
   return v1 > v2;
}

int main()
{
   bool ret1 = CompareNumbers(1, 20);
   bool ret2 = CompareNumbers("b", "a");

   return 0;
}
</pre>
<p>I want this function to be used only for integral types (the reason doesn&#8217;t matter) and I&#8217;d like the compiler to issue an error when used with any other type. Adding a static_assert check will generate a compilation error for the second call to the function, when passing strings.</p>
<pre name="code" class="cpp">
#include < type_traits >

template < typename T >
bool CompareNumbers(T v1, T v2)
{
   static_assert(std::tr1::is_integral< T >::value, "Type is not numeric");
   return v1 > v2;
}
</pre>
<pre class="prettyprint">
1>d:\marius\vc++\cpp0x\cpp0x.cpp(62): error C2338: Type is not numeric
1>          d:\marius\vc++\trainnings\cpp0x\cpp0x.cpp(75) : see reference to function template instantiation 'bool CompareNumbers<const char*>(T,T)' being compiled
1>          with
1>          [
1>              T=const char *
1>          ]
</pre>
<p><strong>auto</strong></p>
<p>If you are familiar with C#, this is the C++ equivalent of var. The keyword is used to deduce the type of a declared variable from its initialization expression. The initialization expression can be an assignment, direct initialization or operator new expression. It must be noted that the auto keyword is just a placeholder, not a type, and cannot be used with sizeof or typeid.</p>
<pre name="code" class="cpp">
auto i = 13;        // i is int
auto s = "marius";  // s is std::string
auto p = new foo(); // p is foo*

vector&lt; int &gt; numbers;
generate_n(back_inserter(numbers), 10, rand);
for(auto it = numbers.begin(); it != numbers.end(); ++it)
{
   cout &lt;&lt; *it &lt;&lt; endl;
}
</pre>
<p><strong>lambda expressions</strong></p>
<p>I already <a href="http://mariusbancila.ro/blog/2009/02/24/lambdas-in-c/">wrote about lambdas</a>, but I will give a short overview again. Again, if you are familiar with C# and .NET, this is the same concept as in .NET.</p>
<p>A lambda functions is a function object whose type is implementation dependent; its type name is only available to the compiler. The lambda expression is composed of several parts:</p>
<ul>
<li>lambda_introducer: this is the part that tells the compiler a lambda function is following. Inside the angled brackets a capture-list can be provided; this is used for capturing variables from the scope in which the lambda is created.</li>
<li>lambda-parameter-declaration: used for specifying the parameters of the lambda function.</li>
<li>lambda-return-type-clause: used for indicating the type returned by the lambda function. This is optional, because most of the time the compiler can infer the type. There are cases when this is not possible and then the type must be specified. For the example above, the return type (-> bool) is not necessary.
</li>
<li>compound-statement: this is the body of the lambda.</li>
</ul>
<pre name="code" class="cpp">
vector&lt;int&gt; numbers;
generate_n(back_inserter(numbers), 10, rand);

for_each(numbers.begin(), numbers.end(), [](int n) {cout &lt;&lt; n &lt;&lt; endl;});
</pre>
<p>Here <em>[]</em> is the lambda introducer, <em>(int n)</em> is the lambda parameter declaration, and <em>{cout << n << endl;}</em> is the lambda compound statement. There is no return type clause, because that is auto inferred by the compiler. There are cases when the compiler cannot deduce the return value and then it must be specified explicitly. A lambda expression is a syntactic shortcut for a functor. The code above is equivalent to:</p>
<pre name="code" class="cpp">
class functor_lambda
{
public:
   void operator()(int n) const
   {
      cout &lt;&lt; n &lt;&lt; endl;
   }
};

vector&lt;int&gt; numbers;
generate_n(back_inserter(numbers), 10, rand);

for_each(numbers.begin(), numbers.end(), functor_lambda());
</pre>
<p>Lambdas can capture variables from their scope by value, reference or both in any combination. In the example above, there was no value captured. This is a stateless lambda. On the other hand, a lambda that captures variables is said to have a state.</p>
<p><strong>rvalue references</strong></p>
<p>Stephan T. Lavavej wrote <a href="http://blogs.msdn.com/vcblog/archive/2009/02/03/rvalue-references-c-0x-features-in-vc10-part-2.aspx">the ultimate guide to rvalue references</a>. There is nothing more that can be said that is not already there. I strongly suggest you read his article to familiarize with this concept.</p>
<p>rvalue references are used to hold a reference to a rvalue or lvalue expression, and are introduced with &#038;&#038;. They enable the implementation of move semantics and perfect forwarding.</p>
<p>Move semantics enable transferring resources from one temporary object to another. This is possible because temporary objects (i.e. rvalues) are not referred anywhere else outside the expression in which they live. To implement move semantics you have to provide a move constructor and optionally a move assignment operator. The Standard Template Library was changed to take advantage of this feature. A classic example for the move semantics is represented by operation with sequences like vector or list. A vector allocates memory for a given number of objects. You can add elements to it and no re-allocation is done until the full capacity is reached. But when that happens, the vector has to reallocate memory. In this case it allocates a new larger chunk, copies all the existing content, and then releases the pervious memory. When an insertion operation needs to copy one element several things happen: a new element is created, its copy constructor is called, and then the old element is destroyed. With moves semantics, the allocation of a new element and its copy is no longer necessary, the existing element can be directly moved.</p>
<p>A second scenario where rvalue references are helpful is the perfect forwarding. The forwarding problem occurs when a generic function takes references as parameters and then needs to forward these parameters to another function. If a generic function takes a parameter of type const T&#038; and needs to call a function that takes T&#038;, it can&#8217;t do that. So you need an overloaded generic function. What rvalue references enable is having one single generic function that takes arbitrary arguments and then forwards them to another function.</p>
<p><strong>decltype operator</strong></p>
<p>This is used to yield the type of an expression. Its primary purpose is for generic programming, in conjunction with auto, for return types of generic functions where the type depends on the arguments of the function. Here are several examples:</p>
<pre name="code" class="cpp">
double d = 42.0;     // decltype(i) yields double
const int&amp;&amp; f();     // decltype(f()) yields const int&amp;&amp;
struct foo {int i;}; // decltype(f.i) yields int (f being an object of type foo)
</pre>
<p>It can be used together with auto to declare late specified return type, with the alternative function declaration syntax, which is (terms in squared brackets indicate optional parts)</p>
<pre name="code" class="cpp">
auto function_name([parameters]) [const] [volatile] -&gt; decltype(expression) [throw] {function_body};
</pre>
<p>In general, the expression use with decltype here should match the expression used in the return statement.</p>
<pre name="code" class="cpp">
struct Liters
{
   double value;
   explicit Liters(double val):value(val){}
};

struct Gallons
{
   double value;
   explicit Gallons(double val):value(val){}
};

ostream&amp; operator&lt;&lt;(ostream&amp; os, const Liters&amp; l)
{
   os &lt;&lt; l.value &lt;&lt; "l";
   return os;
}

ostream&amp; operator&lt;&lt;(ostream&amp; os, const Gallons&amp; g)
{
   os &lt;&lt; g.value &lt;&lt; "gal";
   return os;
}

Liters operator+(const Liters&amp; l1, const Liters&amp; l2)
{
   return Liters(l1.value + l2.value);
}

Gallons operator+(const Gallons&amp; g1, const Gallons&amp; g2)
{
   return Gallons(g1.value + g2.value);
}

Liters operator+(const Liters&amp; l, const Gallons&amp; g)
{
   return Liters(l.value + g.value*3.785);
}

Gallons operator+(const Gallons&amp; g, const Liters&amp; l)
{
   return Gallons(g.value + l.value*0.264);
}

template &lt;typename T1, typename T2&gt;
auto Plus(T1&amp;&amp; v1, T2&amp;&amp; v2) -&gt; decltype(forward&lt; T1 &gt;(v1) + forward&lt; T2 &gt;(v2))
{
   return forward&lt; T1 &gt;(v1) + forward&lt; T2 &gt;(v2);
}

int main()
{
   cout &lt;&lt; Plus(l1, l2) &lt;&lt; endl;
   cout &lt;&lt; Plus(g1, g2) &lt;&lt; endl;
   cout &lt;&lt; Plus(l1, g1) &lt;&lt; endl;
   cout &lt;&lt; Plus(g2, l2) &lt;&lt; endl;

   return 0;
}
</pre>
<p>The result of the execution is:</p>
<blockquote><p>
15l<br />
30gal<br />
42.85l<br />
22.64gal
</p></blockquote>
<p>When function Plus is called with arguments of the same type, the result is that type. But when the arguments differ, the resulting type is also different. In this example, when the first argument is Liters and second is Gallons, the result type must be Liters and the opposite. It is possible to do this without decltype, but the solution requires explicit specification of the resulting type.</p>
<pre name="code" class="cpp">
template &lt;typename T, typename T1, typename T2&gt;
T Plus(T1&amp;&amp; v1, T2&amp;&amp; v2)
{
   return forward&lt; T1 &gt;(v1) + forward&lt; T2 &gt;(v2);
}

int main()
{
   cout &lt;&lt; Plus&lt;Liters&gt;(l1, l2) &lt;&lt; endl;
   cout &lt;&lt; Plus&lt;Gallons&gt;(g1, g2) &lt;&lt; endl;
   cout &lt;&lt; Plus&lt;Liters&gt;(l1, g1) &lt;&lt; endl;
   cout &lt;&lt; Plus&lt;Gallons&gt;(g2, l2) &lt;&lt; endl;

   return 0;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mariusbancila.ro/blog/2010/03/22/visual-studio-2010-changes-for-vc-part-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

