<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: The Joy of C++ Templates Metaprogramming</title>
	<atom:link href="http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/feed/" rel="self" type="application/rss+xml" />
	<link>http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/</link>
	<description>Coin Coin and Plop da Plop</description>
	<pubDate>Wed, 07 Jan 2009 01:46:07 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Julien</title>
		<link>http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/comment-page-1/#comment-330</link>
		<dc:creator>Julien</dc:creator>
		<pubDate>Fri, 14 Sep 2007 06:38:43 +0000</pubDate>
		<guid isPermaLink="false">http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/#comment-330</guid>
		<description>@Fru: thanks for the explanations, but I don't quite get it why using enums would use less memory than static constants. My understanding is that for each instantiation of the template you still have a slot in memory for the enum value... or I am missing something? Please let me know :-)

Even if enum where to consume less memory than constants, they still limit the application of such a technique to normal integer values, hence the need for static constants.</description>
		<content:encoded><![CDATA[<p>@Fru: thanks for the explanations, but I don&#8217;t quite get it why using enums would use less memory than static constants. My understanding is that for each instantiation of the template you still have a slot in memory for the enum value&#8230; or I am missing something? Please let me know <img src='http://jpz-log.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Even if enum where to consume less memory than constants, they still limit the application of such a technique to normal integer values, hence the need for static constants.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fru</title>
		<link>http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/comment-page-1/#comment-329</link>
		<dc:creator>Fru</dc:creator>
		<pubDate>Fri, 14 Sep 2007 05:39:23 +0000</pubDate>
		<guid isPermaLink="false">http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/#comment-329</guid>
		<description>Julien, 
   I don't quite understand Boyan's comment on "cleaning and simplifying", but he *is* correct about your solution wasting memory.  

  He didn't say that your code didn't compute the answer at compile-time (which it does).  He said that your solution doesn't have a zero run-time memory requirement - what he described as "value-free".  Because you're using static variables inside each template instantiation, you will have at least "n" static variables (admittedly, they are const, but they still consume memory space in the program's run time data segment), where each variable is initialized by the compiler's compile time meta-template recursion to the value of Fib(n).

  If you use enums rather than static const variables inside your templates, then you wouldn't use any memory at all.</description>
		<content:encoded><![CDATA[<p>Julien,<br />
   I don&#8217;t quite understand Boyan&#8217;s comment on &#8220;cleaning and simplifying&#8221;, but he *is* correct about your solution wasting memory.  </p>
<p>  He didn&#8217;t say that your code didn&#8217;t compute the answer at compile-time (which it does).  He said that your solution doesn&#8217;t have a zero run-time memory requirement - what he described as &#8220;value-free&#8221;.  Because you&#8217;re using static variables inside each template instantiation, you will have at least &#8220;n&#8221; static variables (admittedly, they are const, but they still consume memory space in the program&#8217;s run time data segment), where each variable is initialized by the compiler&#8217;s compile time meta-template recursion to the value of Fib(n).</p>
<p>  If you use enums rather than static const variables inside your templates, then you wouldn&#8217;t use any memory at all.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: OJ</title>
		<link>http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/comment-page-1/#comment-320</link>
		<dc:creator>OJ</dc:creator>
		<pubDate>Thu, 13 Sep 2007 01:46:59 +0000</pubDate>
		<guid isPermaLink="false">http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/#comment-320</guid>
		<description>Off topic: So what if he only gives negative votes? He can vote how he wishes. Dzone is just a popularity contest anyway. It's just a MySpace for developers. Get over it.

On topic: Personally I find that template metaprogramming can be 'handy'. But to date I've rarely (if ever) found a case where I'd consider using it in production code.</description>
		<content:encoded><![CDATA[<p>Off topic: So what if he only gives negative votes? He can vote how he wishes. Dzone is just a popularity contest anyway. It&#8217;s just a MySpace for developers. Get over it.</p>
<p>On topic: Personally I find that template metaprogramming can be &#8216;handy&#8217;. But to date I&#8217;ve rarely (if ever) found a case where I&#8217;d consider using it in production code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julien</title>
		<link>http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/comment-page-1/#comment-319</link>
		<dc:creator>Julien</dc:creator>
		<pubDate>Wed, 12 Sep 2007 20:34:27 +0000</pubDate>
		<guid isPermaLink="false">http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/#comment-319</guid>
		<description>I guess you are the one whose DZone profile is http://www.dzone.com/users/profile/171944.html

Great... you only give negative votes. I'm impressed ;-)</description>
		<content:encoded><![CDATA[<p>I guess you are the one whose DZone profile is <a href="http://www.dzone.com/users/profile/171944.html" rel="nofollow">http://www.dzone.com/users/profile/171944.html</a></p>
<p>Great&#8230; you only give negative votes. I&#8217;m impressed <img src='http://jpz-log.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julien</title>
		<link>http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/comment-page-1/#comment-318</link>
		<dc:creator>Julien</dc:creator>
		<pubDate>Wed, 12 Sep 2007 20:30:40 +0000</pubDate>
		<guid isPermaLink="false">http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/#comment-318</guid>
		<description>@Boyan: Sorry but I don't agree with your statements.

"Which is not true in your case."

So please show me WHY it is wrong, as in this case everything is calculated at compile-time. Compile the source code and see for yourself... or explain me why the compiler does not perform the computations in this case.

"Try replacing static member variable “value” with “enum{value=…}” for a start."

Yes, I know about enums, but the fact is that enum == int and I wanted to use long long integers rather than int. Having enum {value = ...} or a static constant integer is actually the same...

Enums are one way to do it, but many times you need to manipulate other data types.

"Cleaning and simplifying the code would be next."

???

LOL :-)</description>
		<content:encoded><![CDATA[<p>@Boyan: Sorry but I don&#8217;t agree with your statements.</p>
<p>&#8220;Which is not true in your case.&#8221;</p>
<p>So please show me WHY it is wrong, as in this case everything is calculated at compile-time. Compile the source code and see for yourself&#8230; or explain me why the compiler does not perform the computations in this case.</p>
<p>&#8220;Try replacing static member variable “value” with “enum{value=…}” for a start.&#8221;</p>
<p>Yes, I know about enums, but the fact is that enum == int and I wanted to use long long integers rather than int. Having enum {value = &#8230;} or a static constant integer is actually the same&#8230;</p>
<p>Enums are one way to do it, but many times you need to manipulate other data types.</p>
<p>&#8220;Cleaning and simplifying the code would be next.&#8221;</p>
<p>???</p>
<p>LOL <img src='http://jpz-log.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Boyan</title>
		<link>http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/comment-page-1/#comment-317</link>
		<dc:creator>Boyan</dc:creator>
		<pubDate>Wed, 12 Sep 2007 18:31:21 +0000</pubDate>
		<guid isPermaLink="false">http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/#comment-317</guid>
		<description>The power of meta programming comes (among other things) from the fact that it's value-free, ie. everything is calculated during compile-time and run-time memory requirements are zero.
Which is not true in your case.
Try replacing static member variable "value" with "enum{value=...}" for a start. Cleaning and simplifying the code would be next.</description>
		<content:encoded><![CDATA[<p>The power of meta programming comes (among other things) from the fact that it&#8217;s value-free, ie. everything is calculated during compile-time and run-time memory requirements are zero.<br />
Which is not true in your case.<br />
Try replacing static member variable &#8220;value&#8221; with &#8220;enum{value=&#8230;}&#8221; for a start. Cleaning and simplifying the code would be next.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pierre C</title>
		<link>http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/comment-page-1/#comment-309</link>
		<dc:creator>Pierre C</dc:creator>
		<pubDate>Mon, 10 Sep 2007 06:22:51 +0000</pubDate>
		<guid isPermaLink="false">http://jpz-log.info/archives/2007/09/09/the-joy-of-c-templates-metaprogramming/#comment-309</guid>
		<description>Hello Julien, 

Did you give a look at this wonderful website : http://ktd.club.fr/programmation/cpp-metaprog.php

(Ouille mes chevilles)

+
Chacha</description>
		<content:encoded><![CDATA[<p>Hello Julien, </p>
<p>Did you give a look at this wonderful website : <a href="http://ktd.club.fr/programmation/cpp-metaprog.php" rel="nofollow">http://ktd.club.fr/programmation/cpp-metaprog.php</a></p>
<p>(Ouille mes chevilles)</p>
<p>+<br />
Chacha</p>
]]></content:encoded>
	</item>
</channel>
</rss>
