﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Windreamer Is Not a DREAMER</title><link>http://www.cppblog.com/windreamer/</link><description>&lt;b&gt;main(){main(puts(&lt;font color=brown&gt;"Hello,stranger!"&lt;/font&gt;));}&lt;/b&gt;</description><language>zh-cn</language><lastBuildDate>Mon, 13 Apr 2026 10:48:08 GMT</lastBuildDate><pubDate>Mon, 13 Apr 2026 10:48:08 GMT</pubDate><ttl>60</ttl><item><title>[ZZ]Reconciling Garbage Collection with Deterministic Finalization </title><link>http://www.cppblog.com/windreamer/archive/2006/03/21/4401.html</link><dc:creator>Windreamer Is Not DREAMER</dc:creator><author>Windreamer Is Not DREAMER</author><pubDate>Tue, 21 Mar 2006 02:01:00 GMT</pubDate><guid>http://www.cppblog.com/windreamer/archive/2006/03/21/4401.html</guid><wfw:comment>http://www.cppblog.com/windreamer/comments/4401.html</wfw:comment><comments>http://www.cppblog.com/windreamer/archive/2006/03/21/4401.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/windreamer/comments/commentRss/4401.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/windreamer/services/trackbacks/4401.html</trackback:ping><description><![CDATA[
		<table id="hdropened48842ae2fd029ce6" cellspacing="0" cellpadding="1" border="0">
				<tbody>
						<tr valign="top">
								<td width="25">
										<nobr>
												<b>发件人：</b>
										</nobr>
								</td>
								<td width="2">
								</td>
								<td colspan="2">
										<b>
												<font class="inheritcolor" color="#00681c">Andrei Alexandrescu (See Website For Email)</font>
										</b> </td>
						</tr>
						<tr valign="top">
								<td width="25">
										<nobr>
												<b>日期：</b>
										</nobr>
								</td>
								<td width="2">
								</td>
								<td>2006年3月18日(星期六) 下午12时13分 </td>
						</tr>
						<tr class="scripthide" id="htr1_48842ae2fd029ce6" valign="top">
								<td width="25">
										<nobr>
												<b>电子邮件： </b>
										</nobr>
								</td>
								<td width="2">
								</td>
								<td>"Andrei Alexandrescu (See Website For Email)" &lt;SeeWebsiteForEm<a href="http://groups.google.com/groups/unlock?msg=48842ae2fd029ce6&amp;_done=/group/comp.lang.c%2B%2B.moderated/msg/48842ae2fd029ce6" target="_parent"><font color="#0000cc">...</font></a>@erdani.org&gt;</td>
						</tr>
						<tr class="scripthide" id="htr2_48842ae2fd029ce6" valign="top">
								<td width="25">
										<nobr>
												<b>论坛： </b>
										</nobr>
								</td>
								<td width="2">
								</td>
								<td>comp.lang.c++.moderated</td>
						</tr>
				</tbody>
		</table>
		<div class="mbody" id="mbody48842ae2fd029ce6">
				<p>
						<font size="2">
						</font>
				</p>
				<div style="PADDING-LEFT: 6px">
						<a name="msg_48842ae2fd029ce6">
						</a>
						<font class="fixed_width" face="Courier, Monospaced">
								<font face="Courier New" size="2">The recent thread "Can GC be beneficial" was quite beneficial :o) - to <br />me at least. I've reached a number of conclusions that allow me to <br />better place the conciliation between garbage collection and <br />deterministic finalization in the language design space - in C++ and in <br />general. <br /></font>
								<p>The following discussion focuses on C++-centric considerations, with <br />occasional escapes into "the right thing to do if we could break away <br />with the past. <br /></p>
								<p>Basic Tenets, Constraints, and Desiderata <br />========================================= <br /></p>
								<p>Garbage collection is desirable because: <br /></p>
								<p>(1) It automates a routine and error-prone task <br /></p>
								<p>(2) Reduces client code <br /></p>
								<p>(3) Improves type safety <br /></p>
								<p>(3) Can improve performance, particularly in multithreaded environments <br /></p>
								<p>On the other hand, C++ idioms based on constructors and destructors, <br />including, but not limited to, scoped resource management, have shown to <br />be highly useful. The large applicability of such idioms might actually <br />be the single most important reason for which C++ programmers shy away <br />from migrating to a garbage-collected C++ environment. <br /></p>
								<p>It follows that a set of principled methods that reconcile C++-style <br />programming based on object lifetime, with garbage collection, would be <br />highly desirable for fully exploiting garbage collection's advantages <br />within C++. This article discusses the challenges and to suggests <br />possible designs to address the challenges. <br /></p>
								<p>The constraints include compatibility with existing C++ code and styles <br />of coding, a preference for type safety at least when it doesn't <br />adversely incur a performance hit, and the functioning of today's <br />garbage collection algorithms. <br /></p>
								<p>A Causal Design <br />=============== <br /></p>
								<p>Claim #1: The lifetime management of objects of a class is a decision of <br />the class implementer, not of the class user. <br /></p>
								<p>In support of this claim we come with the following examples: <br /></p>
								<p>a) A class such as complex&lt;double&gt; is oblivious to destruction <br />timeliness because it does not allocate scarce resource that need timely <br />release; <br /></p>
								<p>b) A class such as string doesn't need to worry about destruction <br />timeliness within a GC (Garbage Collected) environment; <br /></p>
								<p>c) A class such as temporary_file does need to worry about destruction <br />timeliness because it allocates scarce resources that transcend both the <br />lifetime of the object (a file handle) and the lifetime of the program <br />(the file on disk that presumably temporary_file needs to delete after <br />usage). <br /></p>
								<p>In all of these examples, the context in which the objects are used is <br />largely irrelevant (barring ill-designed types that employ logical <br />coupling to do entirely different actions depending on their state). <br />There is, therefore, a strong argument that the implementer of a class <br />decides entirely what the destruction regime of the class shall be. This <br />claim will guide design considerations below. <br /></p>
								<p>We'll therefore assume a C++ extension that allows a class definition to <br />include its destruction regime: <br /></p>
								<p> </p>
								<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
										<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> garbage collected </span> <span style="COLOR: #008000"><br />  </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> [collected] Widget </span><span id="Codehighlighter1_47_51_Open_Text"><span style="COLOR: #000000">{...}</span></span><span style="COLOR: #000000">; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> deterministically destroyed </span> <span style="COLOR: #008000"><br />  </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> [deterministic] Midget </span><span id="Codehighlighter1_116_120_Open_Text"><span style="COLOR: #000000">{...}</span></span><span style="COLOR: #000000">; </span></div>
								<p>
										<br />  </p>
								<p>These two possible choices could be naturally complemented by the other <br />allowed storage classes of a class: <br /></p>
								<p> </p>
								<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
										<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> garbage collected or on stack </span> <span style="COLOR: #008000"><br />  </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> [collected, auto] Widget </span><span id="Codehighlighter1_65_69_Open_Text"><span style="COLOR: #000000">{...}</span></span><span style="COLOR: #000000">; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> deterministically destroyed, stack, or static storage </span> <span style="COLOR: #008000"><br />  </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> [deterministic, auto, </span><span style="COLOR: #0000ff">static</span><span style="COLOR: #000000">] Midget </span><span id="Codehighlighter1_174_178_Open_Text"><span style="COLOR: #000000">{...}</span></span><span style="COLOR: #000000">; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span></div>
								<p>
								</p>
								<p>It is illegal, however, that a class specifies both collected and <br />deterministic regime: <br /></p>
								<p> </p>
								<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
										<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> illegal </span> <span style="COLOR: #008000"><br />  </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> [collected, deterministic] Wrong </span><span id="Codehighlighter1_51_55_Open_Text"><span style="COLOR: #000000">{...}</span></span><span style="COLOR: #000000">; </span></div>
								<p>
										<br />  </p>
								<p>Claim #2: Collected types cannot define a destruction-time action. <br /></p>
								<p>This proposal makes this claim in wake of negative experience with <br />Java's finalizers. <br /></p>
								<p>Claim #3: Collected types can transitively only embed fields of <br />collected types (or pointers thereof of any depth), and can only derive <br />from such types. <br /></p>
								<p>If a collected type would have a field of a non-collected type, that <br />type could not be destroyed (as per Claim #2). <br /></p>
								<p>If a collected type would have a field of pointer to a non-collected <br />type, one of two things happens: <br /></p>
								<p>a) A dangling pointer access might occur; <br /></p>
								<p>b) The resource is kept alive indeterminately and as such cannot be <br />destroyed (as per claim #2). <br /></p>
								<p>If a collected type would have a field of pointer to pointer to (notice <br />the double indirection) deterministic type, inevitably that pointer's <br />destination would have to be somehow accessible to the garbage-collected <br />object. This implies that at the some place in the points-to chain, a <br />"jump" must exist from the collected realm to the uncollected realm (be <br />it automatic, static, or deterministic) that would trigger either <br />post-destruction access, or would prevent the destructor to be called. <br /></p>
								<p>Design fork #1: Weak pointers could be supported. A collected type could <br />hold fields of type weak pointer to non-collected types. The weak <br />pointers are tracked and are zeroed automatically during destruction of <br />the resource that they point to. Further dereference attempts accesses <br />from the collected realm become hard errors. <br /></p>
								<p>Claim #4: Deterministic types must track all pointers to their <br />respective objects (via a precise mechanism such as reference counting <br />or reference linking). <br /></p>
								<p>If deterministic types did allow untracked pointer copying, then <br />post-destruction access via dangling pointers might occur. The recent <br />discussion in the thread "Can GC be beneficial" has shown that it is <br />undesirable to define post-destruction access, and it's best to leave it <br />as a hard run-time error. <br /></p>
								<p>Design branch #2: For type safety reasons, disallow type-erasing <br />conversions from/to pointers to deterministic types: <br /></p>
								<p> </p>    
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">   class</span><span style="COLOR: #000000"> [deterministic] Widget </span><span id="Codehighlighter1_29_35_Open_Text"><span style="COLOR: #000000">{...}</span></span><span style="COLOR: #000000">; <br />   Widget </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> p </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Widget; <br /></span><span style="COLOR: #0000ff">   void</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> p1 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> p; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> error </span> <span style="COLOR: #008000"><br />   </span><span style="COLOR: #000000">p </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> static_cast</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">Widget </span><span style="COLOR: #000000">*&gt;</span><span style="COLOR: #000000">(p1); </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> error, too </span></div><p></p><p>Or: For compatibility reasons, allow type-erasing conversion and incur <br />the risk of dangling pointer access. <br /></p><p>Design branch #3: For purpose of having a type that stands in as a <br />pointer to any deterministic type (a sort of "deterministic void*"), all <br />deterministic classes could be thought as (or required to) inherit a <br />class std::deterministic. <br /></p><p>Design branch #3.1: std::deterministic may or may not define virtuals, <br />and as such confines or not all deterministic classes to have virtuals <br />(and be suitable for dynamic_cast among other things). <br /></p><p>Claim #5: When an object of deterministic type is constructed in <br />automatic or static storage, its destructor will automatically issue a <br />hard error if there are any outstanding pointers to it (e.g., the <br />reference count is greater than one). <br /></p><p>If that didn't happen, dangling accesses to expired stack variables <br />might occur: <br /></p><p> </p><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff"> class</span><span style="COLOR: #000000"> [deterministic] Widget </span><span id="Codehighlighter1_29_35_Open_Text"><span style="COLOR: #000000">{...}</span></span><span style="COLOR: #000000">; <br /> Widget </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> p; <br /><img id="Codehighlighter1_62_147_Open_Image" onclick="this.style.display='none'; Codehighlighter1_62_147_Open_Text.style.display='none'; Codehighlighter1_62_147_Closed_Image.style.display='inline'; Codehighlighter1_62_147_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_62_147_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_62_147_Closed_Text.style.display='none'; Codehighlighter1_62_147_Open_Image.style.display='inline'; Codehighlighter1_62_147_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> Fun() </span><span id="Codehighlighter1_62_147_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_62_147_Open_Text"><span style="COLOR: #000000">{ <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    Widget w; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    p </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">w; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> hard runtime error upon exiting this scope </span><span style="COLOR: #008000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"> </span></div><p><br /><br /> </p>Discussion of the basic design <br />============================== <br /><p>The desiderata set up and the constraints of the current C++ language <br />created a causal chain that narrowly guided the possible design of an <br />integrated garbage collection + deterministic destruction in C++: <br /></p><p>* The class author decides whether the class is deterministic or garbage <br />collected <br /></p><p>* As a natural extension, the class author can decide whether objects of <br />that type are allowed to sit on the stack or in static storage. (The <br />regime of automatic and static storage will be discussed below.) <br /></p><p>* Depending on whether a type is deterministic versus collected, the <br />compiler generates different code for copying pointers to the object. <br />Basically the compiler automates usage of smart pointers, a <br />widely-followed semiautomatic discipline in C++. <br /></p><p>* The heap is conceptually segregated into two realms. You can hold <br />unrestricted pointers to objects in the garbage-collected realm, but the <br />garbage-collected realm cannot hold pointers outside of itself. <br /></p><p>* The operations allowed on pointers to deterministic objects are <br />restricted. <br /></p><p>Regime of Automatic Storage <br />=========================== <br /></p><p>Claim 6: Pointers to either deterministic or collected objects that are <br />actually stack allocated should not escape the scope in which their <br />pointee object exists. <br /></p><p>This obvious claim prompts a search in look for an efficient solution to <br />a class of problems. Here is an example: <br /></p><p> </p><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff"> class</span><span style="COLOR: #000000"> [auto, collected] Widget </span><span id="Codehighlighter1_31_37_Open_Text"><span style="COLOR: #000000">{...}</span></span><span style="COLOR: #000000">; <br /><img id="Codehighlighter1_70_97_Open_Image" onclick="this.style.display='none'; Codehighlighter1_70_97_Open_Text.style.display='none'; Codehighlighter1_70_97_Closed_Image.style.display='inline'; Codehighlighter1_70_97_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_70_97_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_70_97_Closed_Text.style.display='none'; Codehighlighter1_70_97_Open_Image.style.display='inline'; Codehighlighter1_70_97_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> Midgetize(Widget </span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000"> obj) </span><span id="Codehighlighter1_70_97_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_70_97_Open_Text"><span style="COLOR: #000000">{ <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    obj.Midgetize(); <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img id="Codehighlighter1_113_172_Open_Image" onclick="this.style.display='none'; Codehighlighter1_113_172_Open_Text.style.display='none'; Codehighlighter1_113_172_Closed_Image.style.display='inline'; Codehighlighter1_113_172_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_113_172_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_113_172_Closed_Text.style.display='none'; Codehighlighter1_113_172_Open_Image.style.display='inline'; Codehighlighter1_113_172_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> Foo() </span><span id="Codehighlighter1_113_172_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_113_172_Open_Text"><span style="COLOR: #000000">{ <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    Widget giantWidget; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    Midgetize(giantWidget); <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"> </span></div><p><br /><br /> </p>To make the example above work, Foo is forced to heap-allocate the <br />Widget object even though the Midgetize function works on it <br />transitorily and stack allocation would suffice. <br /><p>To address this problem a pointer/reference modifier, "auto", can be <br />defined. Its semantics allow only "downward copying": an <br />pointer/reference to auto can only be copied to lesser scope, never to <br />object of larger scope. Examples: <br /></p><p> </p><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img id="Codehighlighter1_11_211_Open_Image" onclick="this.style.display='none'; Codehighlighter1_11_211_Open_Text.style.display='none'; Codehighlighter1_11_211_Closed_Image.style.display='inline'; Codehighlighter1_11_211_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_11_211_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_11_211_Closed_Text.style.display='none'; Codehighlighter1_11_211_Open_Image.style.display='inline'; Codehighlighter1_11_211_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> foo() </span><span id="Codehighlighter1_11_211_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_11_211_Open_Text"><span style="COLOR: #000000">{ <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    Widget w; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    Widget </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">auto p1 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">w1; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> fine, p1 has lesser scope </span><span style="COLOR: #008000"><br /><img id="Codehighlighter1_90_205_Open_Image" onclick="this.style.display='none'; Codehighlighter1_90_205_Open_Text.style.display='none'; Codehighlighter1_90_205_Closed_Image.style.display='inline'; Codehighlighter1_90_205_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_90_205_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_90_205_Closed_Text.style.display='none'; Codehighlighter1_90_205_Open_Image.style.display='inline'; Codehighlighter1_90_205_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" /></span><span style="COLOR: #000000">    </span><span id="Codehighlighter1_90_205_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_90_205_Open_Text"><span style="COLOR: #000000">{ <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />      Widget </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">auto p2 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">w; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> fine </span><span style="COLOR: #008000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">      p2 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> p1; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> fine </span><span style="COLOR: #008000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">      p1 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> p2; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> error! Escaping assignment! </span><span style="COLOR: #008000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" /></span><span style="COLOR: #000000">    }</span></span><span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"> </span></div><p><br /><br /> </p>Then the example above can be made modularly typesafe and efficient like <br />this: <br /><p> </p><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> [auto, collected] Widget </span><span id="Codehighlighter1_31_37_Open_Text"><span style="COLOR: #000000">{...}</span></span><span style="COLOR: #000000">; <br /><img id="Codehighlighter1_74_101_Open_Image" onclick="this.style.display='none'; Codehighlighter1_74_101_Open_Text.style.display='none'; Codehighlighter1_74_101_Closed_Image.style.display='inline'; Codehighlighter1_74_101_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_74_101_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_74_101_Closed_Text.style.display='none'; Codehighlighter1_74_101_Open_Image.style.display='inline'; Codehighlighter1_74_101_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> Midgetize(Widget </span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">auto obj) </span><span id="Codehighlighter1_74_101_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_74_101_Open_Text"><span style="COLOR: #000000">{ <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    obj.Midgetize(); <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img id="Codehighlighter1_117_185_Open_Image" onclick="this.style.display='none'; Codehighlighter1_117_185_Open_Text.style.display='none'; Codehighlighter1_117_185_Closed_Image.style.display='inline'; Codehighlighter1_117_185_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_117_185_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_117_185_Closed_Text.style.display='none'; Codehighlighter1_117_185_Open_Image.style.display='inline'; Codehighlighter1_117_185_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> Foo() </span><span id="Codehighlighter1_117_185_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_117_185_Open_Text"><span style="COLOR: #000000">{ <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    Widget giantWidget; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    Midgetize(giantWidget);  </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> fine </span><span style="COLOR: #008000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span></div><p><br /> </p>Claim #6: "auto"-modified pointers cannot be initialized or assigned <br />from heap-allocated deterministic objects. <br /><p>If "auto"-modified pointers manipulated the reference count, their <br />efficiency advantage would be lost. If they didn't, a type-unsafe <br />situation can easily occur. <br /></p><p>Does operator delete still exist? <br />================================= <br /></p><p>For collected objects, delete is inoperant, as is for static or <br />automatic objects. On a heap-allocated deterministic object, delete can <br />simply check if the reference count is 1, and if so, reassign zero to <br />the pointer. If the reference count is greater than one, issue a hard   <br />error. <br /></p><p>Note that this makes delete entirely secure. There is no way to have a <br />working program that issues a dangling access after delete has been   <br />invoked. <br /></p><p>Regime of Static Storage <br />======================== <br /></p><p>Static storage has the peculiarity that it can easily engender <br />post-destruction access. This is because the order of module <br />initialization is not defined, and therefore cross-module dependencies <br />among objects of static duration are problematic. <br /></p><p>This article delays discussion of the regime of static storage. <br />Hopefully with help from the community, a workable solution to the <br />cross-module initialization would ensue. <br /></p><p>Templates <br />========= <br /></p><p>Claim #7: The collection regime of any type must be accessible during <br />compilation to templated code. <br /></p><p>Here's a simple question: is vector&lt;T&gt; deterministic or collected? <br /></p><p>If it were collected, it couldn't hold deterministic types (because at <br />the end of the day vector&lt;T&gt; must embed a T*). If it were deterministic, <br />collected types couldn't hold vectors of pointers to collected types, <br />which would be a major and gratuitous restriction. <br /></p><p>So the right answer is: vector&lt;T&gt; has the same regime as T. <br /></p><p> </p><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">template </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> T, </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> A</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> <br /><img id="Codehighlighter1_65_104_Open_Image" onclick="this.style.display='none'; Codehighlighter1_65_104_Open_Text.style.display='none'; Codehighlighter1_65_104_Closed_Image.style.display='inline'; Codehighlighter1_65_104_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_65_104_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_65_104_Closed_Text.style.display='none'; Codehighlighter1_65_104_Open_Image.style.display='inline'; Codehighlighter1_65_104_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> [T::collection_regime] vector </span><span id="Codehighlighter1_65_104_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_65_104_Open_Text"><span style="COLOR: #000000">{ </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> or some other syntax </span><span style="COLOR: #008000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">   ... <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000">; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span></div><p><br /> </p>The New World: How Does it Look Like? <br />===================================== <br /><p>After this design almost happening as a natural consequence of an <br />initial set of constraints, the natural question arises: how would <br />programs look like in a C++ with these amenities? <br /></p><p>Below are some considerations: <br /></p><p>* Pointer arithmetic, unions, and casts must be reconsidered (a source <br />of unsafety not thoroughly discussed) <br /></p><p>* Most types would be [collected]. Only a minority of types, those that <br />manage non-memory resources, would live in the deterministic realm. <br /></p><p>* Efficiency of the system will not degrade compared to today's C++. The <br />reduced need for reference-counted resources would allow free and fast <br />pointer copying for many objects; the minority that need care in <br />lifetime management will stay tracked by the compiler, the way they <br />likely were manipulated (by hand) anyway. <br /></p><p>* Given that the compiler can apply advanced analysis to eliminate <br />reference count manipulation in many cases, it is likely that the <br />quality of built-in reference counting would be superior to <br />manually-implemented reference counting, and on a par with advanced <br />manual careful manipulation of a mix of raw and smart pointers. <br /></p><p>---------------------- <br /></p><p>Whew! Please send any comments you have to this group. Thanks! <br /></p><p>Andrei <br /></p><p>      [ See <a href="http://www.gotw.ca/resources/clcm.htm" target="_blank"><font color="#0000cc">http://www.gotw.ca/resources/clcm.htm</font></a> for info about ] <br />      [ comp.lang.c++.moderated.    First time posters: Do this! ] <br /></p></font>
				</div>
		</div>
<img src ="http://www.cppblog.com/windreamer/aggbug/4401.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/windreamer/" target="_blank">Windreamer Is Not DREAMER</a> 2006-03-21 10:01 <a href="http://www.cppblog.com/windreamer/archive/2006/03/21/4401.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[TAOCP杂谈]我的找茬信有了回音……</title><link>http://www.cppblog.com/windreamer/archive/2005/12/16/1814.html</link><dc:creator>Windreamer Is Not DREAMER</dc:creator><author>Windreamer Is Not DREAMER</author><pubDate>Fri, 16 Dec 2005 02:05:00 GMT</pubDate><guid>http://www.cppblog.com/windreamer/archive/2005/12/16/1814.html</guid><wfw:comment>http://www.cppblog.com/windreamer/comments/1814.html</wfw:comment><comments>http://www.cppblog.com/windreamer/archive/2005/12/16/1814.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/windreamer/comments/commentRss/1814.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/windreamer/services/trackbacks/1814.html</trackback:ping><description><![CDATA[<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<P><SPAN style="FONT-SIZE: larger"><B>Is it a mistake in TAOCP</B></SPAN>&nbsp;&nbsp; <BR><SPAN id=_user_mam@theory.stanford.edu>Maggie McLoughlin</SPAN>&nbsp;<FONT color=#00681c>&lt;mam@theory.stanford.edu&gt;</FONT> to Windreamer<BR><BR></P>
<DIV id=mb_1>Sequences with n=0 are empty. It's important in mathematics<BR>to deal with empty sets and strings etc in a meaningful way.<BR>If n = 0 and you're supposed to do something for 1 &lt;= j &lt;= n,<BR>you don't have to do anything.<BR><BR>Thanks for your interest in my book! -- Don Knuth<BR></DIV></BLOCKQUOTE>
<HR>
呵呵，原来是我年少无知了，再次赞一下Knuth爷爷写书的精致<img src ="http://www.cppblog.com/windreamer/aggbug/1814.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/windreamer/" target="_blank">Windreamer Is Not DREAMER</a> 2005-12-16 10:05 <a href="http://www.cppblog.com/windreamer/archive/2005/12/16/1814.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[TAOCP杂谈]第一天，第一章第一节，一个新开始......</title><link>http://www.cppblog.com/windreamer/archive/2005/12/12/1703.html</link><dc:creator>Windreamer Is Not DREAMER</dc:creator><author>Windreamer Is Not DREAMER</author><pubDate>Mon, 12 Dec 2005 13:48:00 GMT</pubDate><guid>http://www.cppblog.com/windreamer/archive/2005/12/12/1703.html</guid><wfw:comment>http://www.cppblog.com/windreamer/comments/1703.html</wfw:comment><comments>http://www.cppblog.com/windreamer/archive/2005/12/12/1703.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cppblog.com/windreamer/comments/commentRss/1703.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/windreamer/services/trackbacks/1703.html</trackback:ping><description><![CDATA[<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<P dir=ltr style="MARGIN-RIGHT: 0px" align=left>要说的话好多，列个提纲先 <IMG height=19 src="http://www.cppblog.com/Emoticons/regular_smile.gif" width=19 border=0><BR><BR></P></BLOCKQUOTE>
<P dir=ltr style="MARGIN-RIGHT: 0px">
<H3>
<UL>
<LI><A href="#feel">TAOCP初读感受——名不虚传的好书 </A>
<LI><A href="#gain">今天的收获——A Bug ? </A>
<LI><A href="#galgo">我的计划——关于Galgo库的"瞎想" </A>
<LI><A href="#step">First Step——Euclid GCD的一个实现 </A>
<LI><A href="#dir">个人觉得今后有研究价值的方向</A></LI></UL></H3>
<HR>

<P align=center><A name=feel><STRONG>TAOCP初读感受</STRONG></A></P><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 《The Art of Computer Programming》</STRONG>的第一卷,大理石花纹的封皮,拿在手里沉甸甸的,这部书给我的第一印象就是这样--"厚重"--带有着神秘感和历史感。<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 其实这部书的中文版前言,我早就有幸拜读过,不过和英文原文相比较,在中文翻译的味道真的是差了很多，我觉得只有读原文才能感到Knuth略带诙谐的而又同是不是严谨的风格，他写文章的风格其实真的挺天马行空的，从写程序扯到做饭，从算法这个词聊起，追着这个词的来历，竟然还带出了莱布尼茨？真晕，开句玩笑，Knuth绝对是那种老顽童型的人物，他这本书达到如此厚度估计此类"废话"功不可没。<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 从Algorithm到Euclid's Algorithm也就是我们熟悉的辗转相除求最大公约数法，我这个算法小白开始进入了他打开的算法世界......<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Knuth行文很喜欢比较、比喻、对比，这让读者看起来很轻松愉悦，不过当他真的玩起数学来，我就有点吃不消了，最后面对算法的一个形式化描述，消耗了我不少精力，不过目前看来还是大致明白了<IMG height=20 src="http://www.cppblog.com/Emoticons/QQ/14.gif" width=20 border=0><BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;总之，这本盛名之下的书，也的确有很多独到的地方，作为计算机科学领域的史诗，它给我的第一印象的确很棒。希望我能坚持着看下去，从中吸收营养。<BR><BR><BR><BR>
<HR>

<P align=center><A name=gain><STRONG>今天的收获</STRONG></A></P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;虽然只看了一节，不过也消耗了我不少的时间和精力（看来别的一些事情也不能太耽误，也要抓紧了）<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;今天的收获很多，首先对算法这个名词有了更多一些的感性认识，Knuth提出的“有限、明确定义、有输入、有输出、有效率”这几个原则总结得真是不错，尤其最前面的两点和效率问题，往往构成了很多复杂的问题，著名的图灵机停机问题大概就是在说这个问题吧……<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;另外对于辗转相除法的一些数学上的推导也给了我不错的感觉，虽然书上没有明确的给一个严格的证明，但是根据他的叙述我马上就体会到了用比较严格的方法如何写这个证明，以及这个证明的关键点（我觉得证明中其实用到了通过双包含来争相等的手法，这个是关键）<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;算法的形式化描述应起了我大的兴趣，回来的路上想，貌似这个好像形成了某种数学结构，而其上的f映射，构成了某种代数结构，没有仔细想过，不过好像是这样子的哦，我觉得貌似算法的本质就是某种自动状态机，只不过不一定是有限状态的吧，至少从他的意思上看是这样的<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;开始没有理解第二个，加上了效率约束的的形式化表达方法的意思，后来花了点时间看了下Ex1.1.8,我觉得我似乎明白了点<BR><BR>我认为Ex1.1.8是这样的一个状态表<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<P align=center>
<TABLE border=1>
<TBODY>
<TR>
<TD>j </TD>
<TD>Theta_j</TD>
<TD>Phi_j</TD>
<TD>a_j</TD>
<TD>b_j</TD></TR>
<TR>
<TD>0</TD>
<TD>a</TD>
<TD>a</TD>
<TD>5</TD>
<TD>1</TD></TR>
<TR>
<TD>1</TD>
<TD>ab</TD>
<TD>c</TD>
<TD>3</TD>
<TD>2</TD></TR>
<TR>
<TD>2</TD>
<TD>bc</TD>
<TD>cb</TD>
<TD>1</TD>
<TD>2</TD></TR>
<TR>
<TD>3</TD>
<TD>b</TD>
<TD>a</TD>
<TD>4</TD>
<TD>3 </TD>
<TR>
<TD>4 
<TD>c 
<TD>b 
<TD>0 
<TD>4 </TD>
<TR>
<TD>5 
<TD>c 
<TD>c 
<TD>5</TD>
<TD>5 </TD></TR></TBODY></TABLE><BR></P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;为了验证，我写了个简单的程序来试验我的状态表（真是不行了，好多东西要翻看手册，写程序的速度总是上不来）<BR><BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">#include&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">iostream</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>#include&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">namespace</SPAN><SPAN style="COLOR: #000000">&nbsp;std;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;main&nbsp;(&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;argc,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">argv[]&nbsp;)<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_96_775_Open_Image onclick="this.style.display='none'; Codehighlighter1_96_775_Open_Text.style.display='none'; Codehighlighter1_96_775_Closed_Image.style.display='inline'; Codehighlighter1_96_775_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_96_775_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_96_775_Closed_Text.style.display='none'; Codehighlighter1_96_775_Open_Image.style.display='inline'; Codehighlighter1_96_775_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_96_775_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_96_775_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #008000"><IMG id=Codehighlighter1_173_215_Open_Image onclick="this.style.display='none'; Codehighlighter1_173_215_Open_Text.style.display='none'; Codehighlighter1_173_215_Closed_Image.style.display='inline'; Codehighlighter1_173_215_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_173_215_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_173_215_Closed_Text.style.display='none'; Codehighlighter1_173_215_Open_Image.style.display='inline'; Codehighlighter1_173_215_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;theta[]</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN id=Codehighlighter1_173_215_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_173_215_Open_Text><SPAN style="COLOR: #000000">{&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">a</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">ab</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">cb</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">b</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">c</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">c</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_234_274_Open_Image onclick="this.style.display='none'; Codehighlighter1_234_274_Open_Text.style.display='none'; Codehighlighter1_234_274_Closed_Image.style.display='inline'; Codehighlighter1_234_274_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_234_274_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_234_274_Closed_Text.style.display='none'; Codehighlighter1_234_274_Open_Image.style.display='inline'; Codehighlighter1_234_274_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;phi&nbsp;&nbsp;[]</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN id=Codehighlighter1_234_274_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_234_274_Open_Text><SPAN style="COLOR: #000000">{&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">a</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">c</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">bc</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">a</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">b</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">c</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_293_335_Open_Image onclick="this.style.display='none'; Codehighlighter1_293_335_Open_Text.style.display='none'; Codehighlighter1_293_335_Closed_Image.style.display='inline'; Codehighlighter1_293_335_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_293_335_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_293_335_Closed_Text.style.display='none'; Codehighlighter1_293_335_Open_Image.style.display='inline'; Codehighlighter1_293_335_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;&nbsp;&nbsp;&nbsp;[]</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN id=Codehighlighter1_293_335_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_293_335_Open_Text><SPAN style="COLOR: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">5</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">3</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">4</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">5</SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_354_396_Open_Image onclick="this.style.display='none'; Codehighlighter1_354_396_Open_Text.style.display='none'; Codehighlighter1_354_396_Closed_Image.style.display='inline'; Codehighlighter1_354_396_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_354_396_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_354_396_Closed_Text.style.display='none'; Codehighlighter1_354_396_Open_Image.style.display='inline'; Codehighlighter1_354_396_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;b&nbsp;&nbsp;&nbsp;&nbsp;[]</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN id=Codehighlighter1_354_396_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_354_396_Open_Text><SPAN style="COLOR: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">3</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">4</SPAN><SPAN style="COLOR: #000000">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000">5</SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;j</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;i</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;stat;<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;getline&nbsp;(cin,stat);<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #0000ff">true</SPAN><SPAN style="COLOR: #000000">)<BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_469_751_Open_Image onclick="this.style.display='none'; Codehighlighter1_469_751_Open_Text.style.display='none'; Codehighlighter1_469_751_Closed_Image.style.display='inline'; Codehighlighter1_469_751_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_469_751_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_469_751_Closed_Text.style.display='none'; Codehighlighter1_469_751_Open_Image.style.display='inline'; Codehighlighter1_469_751_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_469_751_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_469_751_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;loc</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">stat.find(theta[j],</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(loc</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">::npos)<BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_540_555_Open_Image onclick="this.style.display='none'; Codehighlighter1_540_555_Open_Text.style.display='none'; Codehighlighter1_540_555_Closed_Image.style.display='inline'; Codehighlighter1_540_555_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_540_555_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_540_555_Closed_Text.style.display='none'; Codehighlighter1_540_555_Open_Image.style.display='inline'; Codehighlighter1_540_555_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_540_555_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_540_555_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;j</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">a[j];<BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_566_672_Open_Image onclick="this.style.display='none'; Codehighlighter1_566_672_Open_Text.style.display='none'; Codehighlighter1_566_672_Closed_Image.style.display='inline'; Codehighlighter1_566_672_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_566_672_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_566_672_Closed_Text.style.display='none'; Codehighlighter1_566_672_Open_Image.style.display='inline'; Codehighlighter1_566_672_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_566_672_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_566_672_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">26</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;temp</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">stat.substr(</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,loc)</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">phi[j]</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">stat.substr(loc</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">theta[j].length());<BR></SPAN><SPAN style="COLOR: #008080">27</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stat</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">temp;<BR></SPAN><SPAN style="COLOR: #008080">28</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;j</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">b[j];<BR></SPAN><SPAN style="COLOR: #008080">29</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">30</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</SPAN><SPAN style="COLOR: #000000">&lt;&lt;</SPAN><SPAN style="COLOR: #000000">i</SPAN><SPAN style="COLOR: #000000">++&lt;&lt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">:\tj(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;&lt;</SPAN><SPAN style="COLOR: #000000">j</SPAN><SPAN style="COLOR: #000000">&lt;&lt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)\tloc(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;&lt;</SPAN><SPAN style="COLOR: #000000">loc</SPAN><SPAN style="COLOR: #000000">&lt;&lt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)\t</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;&lt;</SPAN><SPAN style="COLOR: #000000">stat</SPAN><SPAN style="COLOR: #000000">&lt;&lt;</SPAN><SPAN style="COLOR: #000000">endl;<BR></SPAN><SPAN style="COLOR: #008080">31</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cin.</SPAN><SPAN style="COLOR: #0000ff">get</SPAN><SPAN style="COLOR: #000000">();<BR></SPAN><SPAN style="COLOR: #008080">32</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">33</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;EXIT_SUCCESS;<BR></SPAN><SPAN style="COLOR: #008080">34</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_780_829_Open_Image onclick="this.style.display='none'; Codehighlighter1_780_829_Open_Text.style.display='none'; Codehighlighter1_780_829_Closed_Image.style.display='inline'; Codehighlighter1_780_829_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_780_829_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_780_829_Closed_Text.style.display='none'; Codehighlighter1_780_829_Open_Image.style.display='inline'; Codehighlighter1_780_829_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_780_829_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_780_829_Open_Text><SPAN style="COLOR: #008000">/*</SPAN><SPAN style="COLOR: #008000">&nbsp;----------&nbsp;&nbsp;end&nbsp;of&nbsp;function&nbsp;main&nbsp;&nbsp;----------&nbsp;</SPAN><SPAN style="COLOR: #008000">*/</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">35</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;最后一定要提的是，我好像发现了书里的一处小Bug，而且好像官方网站里的Errata里面没有这个（中文版同样有这个问题），我已经写信给Knuth了，希望我是真的找到了一个没人发现的Bug啊（其实我知道这个不可能）<BR><BR><BR>
<HR>

<P align=center><BR><A name=galgo><STRONG>关于Galgo库的"瞎想"</STRONG></A><BR></P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;念叨做一个泛型的算法库已经有好长时间了，我觉得这个事情与其一直这么YY，还不如高兴了就写一点，不高兴，就扔着,</P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;其实，这个世界是不缺泛型算法库的，STL，Boost，Blitz++中的泛型算法很全面了，我的计划是把他们中间缺少的部分补起来，不能互操作的地方粘合起来，再有就是增加对MetaProgramming的支持<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;呵呵，应该还算是一个比较雄伟的计划吧<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;我希望这套库能尽可能的高效率、容易使用、同事保证安全，理想的境地是能够代替ACM集训队使用的模块<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;目前我的设想是整个库放在Galgo这个namespace里，这个namespace分为两个子namespace，分别是泛型算法Generic和元编程算法Meta<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;我觉得这样一个库的建立与维护，任重而道远不说，没准前人已经作过360遍了，不过没关系，权当娱乐了。<BR><BR>
<HR>

<P align=center><BR><A name=step><STRONG>First Step——Euclid GCD的一个实现 </STRONG></A><BR></P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;不说什么废话了，先贴代码：<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">-------------------------------BEGIN:GAlgo_Euclid_GCD.hpp--------------------------</SPAN><SPAN style="COLOR: #008000">//<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">#ifndef&nbsp;_GAlgo_Euclid_GCD_H_<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">#define</SPAN><SPAN style="COLOR: #000000">&nbsp;_GAlgo_Euclid_GCD_H_</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">namespace</SPAN><SPAN style="COLOR: #000000">&nbsp;GAlgo<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_162_512_Open_Image onclick="this.style.display='none'; Codehighlighter1_162_512_Open_Text.style.display='none'; Codehighlighter1_162_512_Closed_Image.style.display='inline'; Codehighlighter1_162_512_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_162_512_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_162_512_Closed_Text.style.display='none'; Codehighlighter1_162_512_Open_Image.style.display='inline'; Codehighlighter1_162_512_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_162_512_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_162_512_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">namespace</SPAN><SPAN style="COLOR: #000000">&nbsp;Generic<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_184_299_Open_Image onclick="this.style.display='none'; Codehighlighter1_184_299_Open_Text.style.display='none'; Codehighlighter1_184_299_Closed_Image.style.display='inline'; Codehighlighter1_184_299_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_184_299_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_184_299_Closed_Text.style.display='none'; Codehighlighter1_184_299_Open_Image.style.display='inline'; Codehighlighter1_184_299_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_184_299_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_184_299_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">typename&nbsp;T</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T&nbsp;Euclid_GCD(</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&nbsp;T</SPAN><SPAN style="COLOR: #000000">&amp;</SPAN><SPAN style="COLOR: #000000">&nbsp;a,</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&nbsp;T</SPAN><SPAN style="COLOR: #000000">&amp;</SPAN><SPAN style="COLOR: #000000">&nbsp;b)<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_250_296_Open_Image onclick="this.style.display='none'; Codehighlighter1_250_296_Open_Text.style.display='none'; Codehighlighter1_250_296_Closed_Image.style.display='inline'; Codehighlighter1_250_296_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_250_296_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_250_296_Closed_Text.style.display='none'; Codehighlighter1_250_296_Open_Image.style.display='inline'; Codehighlighter1_250_296_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_250_296_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_250_296_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;((a</SPAN><SPAN style="COLOR: #000000">%</SPAN><SPAN style="COLOR: #000000">b)</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN style="COLOR: #000000">?</SPAN><SPAN style="COLOR: #000000">b:Euclid_GCD(b,a</SPAN><SPAN style="COLOR: #000000">%</SPAN><SPAN style="COLOR: #000000">b);<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">namespace</SPAN><SPAN style="COLOR: #000000">&nbsp;Meta<BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_318_510_Open_Image onclick="this.style.display='none'; Codehighlighter1_318_510_Open_Text.style.display='none'; Codehighlighter1_318_510_Closed_Image.style.display='inline'; Codehighlighter1_318_510_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_318_510_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_318_510_Closed_Text.style.display='none'; Codehighlighter1_318_510_Open_Image.style.display='inline'; Codehighlighter1_318_510_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_318_510_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_318_510_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;A,</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;B</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;Euclid_GCD<BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_367_423_Open_Image onclick="this.style.display='none'; Codehighlighter1_367_423_Open_Text.style.display='none'; Codehighlighter1_367_423_Closed_Image.style.display='inline'; Codehighlighter1_367_423_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_367_423_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_367_423_Closed_Text.style.display='none'; Codehighlighter1_367_423_Open_Image.style.display='inline'; Codehighlighter1_367_423_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_367_423_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_367_423_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;value</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">Euclid_GCD</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">B,A</SPAN><SPAN style="COLOR: #000000">%</SPAN><SPAN style="COLOR: #000000">B</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">::value;<BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;A</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;Euclid_GCD</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">A,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_473_506_Open_Image onclick="this.style.display='none'; Codehighlighter1_473_506_Open_Text.style.display='none'; Codehighlighter1_473_506_Closed_Image.style.display='inline'; Codehighlighter1_473_506_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_473_506_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_473_506_Closed_Text.style.display='none'; Codehighlighter1_473_506_Open_Image.style.display='inline'; Codehighlighter1_473_506_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_473_506_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_473_506_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;value</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">A;<BR></SPAN><SPAN style="COLOR: #008080">26</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">27</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">28</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">29</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">#endif</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">30</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">31</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">-------------------------------END:GAlgo_Euclid_GCD.hpp--------------------------</SPAN><SPAN style="COLOR: #008000">//</SPAN></DIV><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;应该没什么好说的，比较中规中矩，常规手法，不过根据TAOCP上的说法，可能在某些m，n的取值上需要很多重的递归这时候Meta的方法可能会遇到困难（其实第一种也有运行时堆栈溢出的危险），所以说……说什么好呢，就这样了<BR><BR>下面是个简单的测试<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">#include&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">GAlgo_Euclid_GCD.hpp</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>#include&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">iostream</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">namespace</SPAN><SPAN style="COLOR: #000000">&nbsp;std;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;main()<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_85_194_Open_Image onclick="this.style.display='none'; Codehighlighter1_85_194_Open_Text.style.display='none'; Codehighlighter1_85_194_Closed_Image.style.display='inline'; Codehighlighter1_85_194_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_85_194_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_85_194_Closed_Text.style.display='none'; Codehighlighter1_85_194_Open_Image.style.display='inline'; Codehighlighter1_85_194_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_85_194_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_85_194_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;cout</SPAN><SPAN style="COLOR: #000000">&lt;&lt;</SPAN><SPAN style="COLOR: #000000">GAlgo::Generic::Euclid_GCD(</SPAN><SPAN style="COLOR: #000000">6</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">9</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN style="COLOR: #000000">&lt;&lt;</SPAN><SPAN style="COLOR: #000000">endl;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;cout</SPAN><SPAN style="COLOR: #000000">&lt;&lt;</SPAN><SPAN style="COLOR: #000000">GAlgo::Meta::Euclid_GCD</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">6</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">9</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">::value</SPAN><SPAN style="COLOR: #000000">&lt;&lt;</SPAN><SPAN style="COLOR: #000000">endl;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><BR>
<HR>

<P align=center><BR><A name=dir><STRONG>个人觉得今后有研究价值的方向</STRONG></A><BR></P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;我觉得对于算法描述和图灵机、有限状态机、以及隐隐约约我看到的马尔科夫的某些工作（马尔科夫链）之间的关系深入挖掘一下应该会有不少收获，那个我对这个问题可能会有一个数学结构的猜想估计也可能可以在这个方向上证实或证伪……<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;突然想去向偶像黄兆镇请教一下……还是等我把胆子先练大再去吧……<img src ="http://www.cppblog.com/windreamer/aggbug/1703.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/windreamer/" target="_blank">Windreamer Is Not DREAMER</a> 2005-12-12 21:48 <a href="http://www.cppblog.com/windreamer/archive/2005/12/12/1703.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[书评]《C++Templates》</title><link>http://www.cppblog.com/windreamer/archive/2005/12/10/1657.html</link><dc:creator>Windreamer Is Not DREAMER</dc:creator><author>Windreamer Is Not DREAMER</author><pubDate>Sat, 10 Dec 2005 04:36:00 GMT</pubDate><guid>http://www.cppblog.com/windreamer/archive/2005/12/10/1657.html</guid><wfw:comment>http://www.cppblog.com/windreamer/comments/1657.html</wfw:comment><comments>http://www.cppblog.com/windreamer/archive/2005/12/10/1657.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/windreamer/comments/commentRss/1657.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/windreamer/services/trackbacks/1657.html</trackback:ping><description><![CDATA[<P>终于无聊到来写书评，最近的项目一直都没和C++有什么关系，不过看的书却都是C++方面的，而最近看到的几本书中感觉最好的莫过于这本《C++ Templates》<BR><BR>Nicolai M. Josuttis的书我很喜欢，从他的那本《The C++ Standard Template Library》就看出了他很多独特的风格，令我爱不释手，所以这本《C++ Template》&nbsp;&nbsp; 也进入了我的必看书单。粗读之后，感觉整本书绝对将成为C++泛型领域的圣经级著作<BR><BR>
<OL>
<LI>这本书角度选得很好，全书分三个部分，分别介绍模板基础、模版的编译器实现、模板的高级技巧，三个部分相辅相成、相互照应，由浅入深而又自然而然，还方便分开阅读（比如我就重点看了第一第三部分，模版实现被我略过了<IMG height=19 src="http://www.cppblog.com/Emoticons/72_72.gif" width=19 border=0>）却又全面覆盖了这一领域<BR>
<LI>这本书英文很浅显（比《Modern C++ Design》浅显了不知多少倍），语言严谨而又不晦涩，尤其要赞的就是废话尤其地少！<BR>
<LI>章节安排很合理，很方别作为工具书应急查阅（《C++STL》就有这个优点，与这本书科学家+工程师的组合不无关系）<BR>
<LI>书中好多技术，我是闻所未闻，惊为天人，尤其第三部分，可以算得上眼花缭乱，而且给出的实现感觉既符合标准、实用、而且没有炫技的成分</LI></OL>
<P>同类书籍据我所知没有可以达到这个高度的，大部分C++泛型方面的专著只局限于怎么用STL，将模板基础的书，也仅限于最表面的语法，像模版参数推导这种问题鲜有涉及，更不用提关于Metaprogramming，这本书圣经的地位估计后人也是难以企及了。</P>
<P>下面是我看书时画下来的一些觉得自己平时应该注意的地方，放在这里做备忘好了<BR><BR></P>
<OL>
<LI>(P12)&nbsp;[Argument Deducion] If we pass two <STRONG>ints</STRONG> to the parameter type <STRONG>T const&amp;&nbsp; </STRONG>the C++ compiler must conclude that T must be <STRONG>int</STRONG>. <U>Note that no automatic type conversion is allowed here,Each <STRONG>T</STRONG> must match exactly.<BR><BR></U>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">typename&nbsp;T</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>inline&nbsp;T&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&amp;</SPAN><SPAN style="COLOR: #000000">&nbsp;max&nbsp;(T&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&amp;</SPAN><SPAN style="COLOR: #000000">&nbsp;a,T&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&amp;</SPAN><SPAN style="COLOR: #000000">&nbsp;b);<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><IMG src="http://www.cppblog.com/images/dot.gif"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>max(</SPAN><SPAN style="COLOR: #000000">4</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">7</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">OK:T&nbsp;is&nbsp;int&nbsp;for&nbsp;both&nbsp;arguments</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">max(</SPAN><SPAN style="COLOR: #000000">4</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">4.2</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">ERROR:first&nbsp;T&nbsp;is&nbsp;int,second&nbsp;T&nbsp;is&nbsp;double</SPAN></DIV><BR>
<LI>(P13)[Template Parameters] In function templates(unlike class template) no default template arguments can be specified<BR>
<LI>(P14)[Template Parameters]Deducation can be seen as part of&nbsp; overlaod resolution-a process tha is not based on selection of return type either.The sole exception is the return type of conversion operator members.<BR>
<LI>(P18)[Overloading Function Template] The fact that not all overloaded functions are visible when a corresponding function call is made may or may not matter.<BR>
<LI>(P39)[Nontype Function Template Parameters] Function templates are considered to name a set of overloaded function.However,according to the current standard,sets of overload functions cannot be used for template parameter deducation.Thus you have to cast to the exactly type of the function template arguments<BR><BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">typename&nbsp;T,</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;VAL</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>T&nbsp;addValue&nbsp;(T&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&amp;</SPAN><SPAN style="COLOR: #000000">&nbsp;x)<BR><IMG id=Codehighlighter1_54_73_Open_Image onclick="this.style.display='none'; Codehighlighter1_54_73_Open_Text.style.display='none'; Codehighlighter1_54_73_Closed_Image.style.display='inline'; Codehighlighter1_54_73_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_54_73_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_54_73_Closed_Text.style.display='none'; Codehighlighter1_54_73_Open_Image.style.display='inline'; Codehighlighter1_54_73_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_54_73_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_54_73_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;x</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">VAL<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>std::transform(source.begin(),source.end(),</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">start&nbsp;and&nbsp;end&nbsp;of&nbsp;source</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">dest.begin(),</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">start&nbsp;of&nbsp;destination</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">)(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&amp;</SPAN><SPAN style="COLOR: #000000">))addValue</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">5</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">);</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">operation<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><BR>
<LI>(P40)[Restrictions for Nontype Template Parameters] 太长了，略过<BR>
<LI>(P44)[The .template Construct]<BR><BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;N</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;printBitset&nbsp;(std::bitset</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">N</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&amp;</SPAN><SPAN style="COLOR: #000000">&nbsp;bs)<BR><IMG id=Codehighlighter1_61_172_Open_Image onclick="this.style.display='none'; Codehighlighter1_61_172_Open_Text.style.display='none'; Codehighlighter1_61_172_Closed_Image.style.display='inline'; Codehighlighter1_61_172_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_61_172_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_61_172_Closed_Text.style.display='none'; Codehighlighter1_61_172_Open_Image.style.display='inline'; Codehighlighter1_61_172_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_61_172_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_61_172_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;std::cout</SPAN><SPAN style="COLOR: #000000">&lt;&lt;</SPAN><SPAN style="COLOR: #000000">bs.to_string</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">,char_traits</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">,allacator</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">();</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">ERROR:can't&nbsp;recogonize&nbsp;the&nbsp;template</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;N</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;printBitset&nbsp;(std::bitset</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">N</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&amp;</SPAN><SPAN style="COLOR: #000000">&nbsp;bs)<BR><IMG id=Codehighlighter1_236_323_Open_Image onclick="this.style.display='none'; Codehighlighter1_236_323_Open_Text.style.display='none'; Codehighlighter1_236_323_Closed_Image.style.display='inline'; Codehighlighter1_236_323_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_236_323_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_236_323_Closed_Text.style.display='none'; Codehighlighter1_236_323_Open_Image.style.display='inline'; Codehighlighter1_236_323_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_236_323_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_236_323_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;std::cout</SPAN><SPAN style="COLOR: #000000">&lt;&lt;</SPAN><SPAN style="COLOR: #000000">bs.template&nbsp;to_string</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">,char_traits</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">,allacator</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">();</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">OK</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN></DIV><BR>
<LI>(P45)[Using this-&gt;]<BR><BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">typename&nbsp;T</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;Base<BR><IMG id=Codehighlighter1_33_59_Open_Image onclick="this.style.display='none'; Codehighlighter1_33_59_Open_Text.style.display='none'; Codehighlighter1_33_59_Closed_Image.style.display='inline'; Codehighlighter1_33_59_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_33_59_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_33_59_Closed_Text.style.display='none'; Codehighlighter1_33_59_Open_Image.style.display='inline'; Codehighlighter1_33_59_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_33_59_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_33_59_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">:<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;bar();<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">typename&nbsp;T</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;Derived&nbsp;:&nbsp;Base</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">T</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_109_191_Open_Image onclick="this.style.display='none'; Codehighlighter1_109_191_Open_Text.style.display='none'; Codehighlighter1_109_191_Closed_Image.style.display='inline'; Codehighlighter1_109_191_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_109_191_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_109_191_Closed_Text.style.display='none'; Codehighlighter1_109_191_Open_Image.style.display='inline'; Codehighlighter1_109_191_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_109_191_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_109_191_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">:<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;foo()<BR><IMG id=Codehighlighter1_138_189_Open_Image onclick="this.style.display='none'; Codehighlighter1_138_189_Open_Text.style.display='none'; Codehighlighter1_138_189_Closed_Image.style.display='inline'; Codehighlighter1_138_189_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_138_189_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_138_189_Closed_Text.style.display='none'; Codehighlighter1_138_189_Open_Image.style.display='inline'; Codehighlighter1_138_189_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_138_189_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_138_189_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bar();</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">call&nbsp;external&nbsp;bar()&nbsp;or&nbsp;error</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">typename&nbsp;T</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;Derived&nbsp;:&nbsp;Base</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">T</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_240_302_Open_Image onclick="this.style.display='none'; Codehighlighter1_240_302_Open_Text.style.display='none'; Codehighlighter1_240_302_Closed_Image.style.display='inline'; Codehighlighter1_240_302_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_240_302_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_240_302_Closed_Text.style.display='none'; Codehighlighter1_240_302_Open_Image.style.display='inline'; Codehighlighter1_240_302_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_240_302_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_240_302_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">:<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;foo()<BR><IMG id=Codehighlighter1_269_300_Open_Image onclick="this.style.display='none'; Codehighlighter1_269_300_Open_Text.style.display='none'; Codehighlighter1_269_300_Closed_Image.style.display='inline'; Codehighlighter1_269_300_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_269_300_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_269_300_Closed_Text.style.display='none'; Codehighlighter1_269_300_Open_Image.style.display='inline'; Codehighlighter1_269_300_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_269_300_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_269_300_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">-&gt;</SPAN><SPAN style="COLOR: #000000">bar();</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">OK</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV><BR>
<LI>同样精彩的还有(P57)[Using String Literals as Arguments for Function Templates]<BR>
<LI>令我惊异的SFINE技术(substitution-failure-is-not-an-error)<BR><BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">typename&nbsp;T</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;IsClassT<BR><IMG id=Codehighlighter1_37_287_Open_Image onclick="this.style.display='none'; Codehighlighter1_37_287_Open_Text.style.display='none'; Codehighlighter1_37_287_Closed_Image.style.display='inline'; Codehighlighter1_37_287_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_37_287_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_37_287_Closed_Text.style.display='none'; Codehighlighter1_37_287_Open_Image.style.display='inline'; Codehighlighter1_37_287_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_37_287_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_37_287_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">:<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">&nbsp;One;<BR><IMG id=Codehighlighter1_89_100_Open_Image onclick="this.style.display='none'; Codehighlighter1_89_100_Open_Text.style.display='none'; Codehighlighter1_89_100_Closed_Image.style.display='inline'; Codehighlighter1_89_100_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_89_100_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_89_100_Closed_Text.style.display='none'; Codehighlighter1_89_100_Open_Image.style.display='inline'; Codehighlighter1_89_100_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;</SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_89_100_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_89_100_Open_Text><SPAN style="COLOR: #000000">{</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">&nbsp;a[</SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">];}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;Two;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">typename&nbsp;C</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;One&nbsp;test&nbsp;(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">::C</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">typename&nbsp;C</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;Two&nbsp;test(<IMG src="http://www.cppblog.com/images/dot.gif">);<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">:<BR><IMG id=Codehighlighter1_225_264_Open_Image onclick="this.style.display='none'; Codehighlighter1_225_264_Open_Text.style.display='none'; Codehighlighter1_225_264_Closed_Image.style.display='inline'; Codehighlighter1_225_264_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_225_264_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_225_264_Closed_Text.style.display='none'; Codehighlighter1_225_264_Open_Image.style.display='inline'; Codehighlighter1_225_264_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">enum</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_225_264_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_225_264_Open_Text><SPAN style="COLOR: #000000">{Yes</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #0000ff">sizeof</SPAN><SPAN style="COLOR: #000000">(IsClassT</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">T</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">::test</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">T</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">))</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG id=Codehighlighter1_276_284_Open_Image onclick="this.style.display='none'; Codehighlighter1_276_284_Open_Text.style.display='none'; Codehighlighter1_276_284_Closed_Image.style.display='inline'; Codehighlighter1_276_284_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_276_284_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_276_284_Closed_Text.style.display='none'; Codehighlighter1_276_284_Open_Image.style.display='inline'; Codehighlighter1_276_284_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">enum</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_276_284_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_276_284_Open_Text><SPAN style="COLOR: #000000">{No</SPAN><SPAN style="COLOR: #000000">=!</SPAN><SPAN style="COLOR: #000000">Yes}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;</SPAN></DIV></LI></OL><BR>总而言之，此书带给了我前所未有的阅读享受......我今年震撼大奖一定会投它一票<img src ="http://www.cppblog.com/windreamer/aggbug/1657.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/windreamer/" target="_blank">Windreamer Is Not DREAMER</a> 2005-12-10 12:36 <a href="http://www.cppblog.com/windreamer/archive/2005/12/10/1657.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>把我的技术博客放在在这里了</title><link>http://www.cppblog.com/windreamer/archive/2005/12/05/1536.html</link><dc:creator>Windreamer Is Not DREAMER</dc:creator><author>Windreamer Is Not DREAMER</author><pubDate>Mon, 05 Dec 2005 01:45:00 GMT</pubDate><guid>http://www.cppblog.com/windreamer/archive/2005/12/05/1536.html</guid><wfw:comment>http://www.cppblog.com/windreamer/comments/1536.html</wfw:comment><comments>http://www.cppblog.com/windreamer/archive/2005/12/05/1536.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/windreamer/comments/commentRss/1536.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/windreamer/services/trackbacks/1536.html</trackback:ping><description><![CDATA[主要喜欢他的语法着色功能，真的很方便，RSS等方面的功能也很全面......<IMG height=19 src="http://www.cppblog.com/Emoticons/regular_smile.gif" width=19 border=0><BR><BR>测试一下：<BR><BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG id=Codehighlighter1_0_30_Open_Image onclick="this.style.display='none'; Codehighlighter1_0_30_Open_Text.style.display='none'; Codehighlighter1_0_30_Closed_Image.style.display='inline'; Codehighlighter1_0_30_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_0_30_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_0_30_Closed_Text.style.display='none'; Codehighlighter1_0_30_Open_Image.style.display='inline'; Codehighlighter1_0_30_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN id=Codehighlighter1_0_30_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_0_30_Open_Text><SPAN style="COLOR: #808080">//////////////////////////////</SPAN></SPAN><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">Prime.cpp</SPAN><SPAN style="COLOR: #008000"><BR><IMG id=Codehighlighter1_43_73_Open_Image onclick="this.style.display='none'; Codehighlighter1_43_73_Open_Text.style.display='none'; Codehighlighter1_43_73_Closed_Image.style.display='inline'; Codehighlighter1_43_73_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_43_73_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_43_73_Closed_Text.style.display='none'; Codehighlighter1_43_73_Open_Image.style.display='inline'; Codehighlighter1_43_73_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_43_73_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_43_73_Open_Text><SPAN style="COLOR: #808080">//////////////////////////////</SPAN></SPAN><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>template</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;Val</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;IntType<BR><IMG id=Codehighlighter1_108_142_Open_Image onclick="this.style.display='none'; Codehighlighter1_108_142_Open_Text.style.display='none'; Codehighlighter1_108_142_Closed_Image.style.display='inline'; Codehighlighter1_108_142_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_108_142_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_108_142_Closed_Text.style.display='none'; Codehighlighter1_108_142_Open_Image.style.display='inline'; Codehighlighter1_108_142_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_108_142_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_108_142_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;value&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;Val&nbsp;;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>template</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">bool</SPAN><SPAN style="COLOR: #000000">&nbsp;flag,&nbsp;typename&nbsp;T,&nbsp;typename&nbsp;U</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;Select<BR><IMG id=Codehighlighter1_203_224_Open_Image onclick="this.style.display='none'; Codehighlighter1_203_224_Open_Text.style.display='none'; Codehighlighter1_203_224_Closed_Image.style.display='inline'; Codehighlighter1_203_224_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_203_224_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_203_224_Closed_Text.style.display='none'; Codehighlighter1_203_224_Open_Image.style.display='inline'; Codehighlighter1_203_224_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_203_224_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_203_224_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;typedef&nbsp;T&nbsp;Result;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>template</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">typename&nbsp;T,&nbsp;typename&nbsp;U</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;Select</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">false</SPAN><SPAN style="COLOR: #000000">,&nbsp;T,&nbsp;U</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_288_309_Open_Image onclick="this.style.display='none'; Codehighlighter1_288_309_Open_Text.style.display='none'; Codehighlighter1_288_309_Closed_Image.style.display='inline'; Codehighlighter1_288_309_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_288_309_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_288_309_Closed_Text.style.display='none'; Codehighlighter1_288_309_Open_Image.style.display='inline'; Codehighlighter1_288_309_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_288_309_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_288_309_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;typedef&nbsp;U&nbsp;Result;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">unsigned&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;N,unsigned&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;x</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;FindRoot<BR><IMG id=Codehighlighter1_369_478_Open_Image onclick="this.style.display='none'; Codehighlighter1_369_478_Open_Text.style.display='none'; Codehighlighter1_369_478_Closed_Image.style.display='inline'; Codehighlighter1_369_478_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_369_478_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_369_478_Closed_Text.style.display='none'; Codehighlighter1_369_478_Open_Image.style.display='inline'; Codehighlighter1_369_478_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_369_478_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_369_478_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;value</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">Select</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">(N</SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">x)</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">x</SPAN><SPAN style="COLOR: #000000">||</SPAN><SPAN style="COLOR: #000000">((N</SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">x</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">x)</SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">x),IntType</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">x</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">,FindRoot</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">N,(N</SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">x</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">x)</SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">::Result::value;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">unsigned&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;N</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;Sqrt<BR><IMG id=Codehighlighter1_520_570_Open_Image onclick="this.style.display='none'; Codehighlighter1_520_570_Open_Text.style.display='none'; Codehighlighter1_520_570_Closed_Image.style.display='inline'; Codehighlighter1_520_570_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_520_570_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_520_570_Closed_Text.style.display='none'; Codehighlighter1_520_570_Open_Image.style.display='inline'; Codehighlighter1_520_570_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_520_570_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_520_570_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;value</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">FindRoot</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">N,N</SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">::value;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;Sqrt</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;N,</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;divider</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;TestPrime<BR><IMG id=Codehighlighter1_650_750_Open_Image onclick="this.style.display='none'; Codehighlighter1_650_750_Open_Text.style.display='none'; Codehighlighter1_650_750_Closed_Image.style.display='inline'; Codehighlighter1_650_750_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_650_750_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_650_750_Closed_Text.style.display='none'; Codehighlighter1_650_750_Open_Image.style.display='inline'; Codehighlighter1_650_750_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_650_750_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_650_750_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;value</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">Select</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">(N</SPAN><SPAN style="COLOR: #000000">%</SPAN><SPAN style="COLOR: #000000">divider)</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,IntType</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">,TestPrime</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">N,divider</SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">::Result::value;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;N</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;TestPrime</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">N,</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_793_822_Open_Image onclick="this.style.display='none'; Codehighlighter1_793_822_Open_Text.style.display='none'; Codehighlighter1_793_822_Closed_Image.style.display='inline'; Codehighlighter1_793_822_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_793_822_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_793_822_Closed_Text.style.display='none'; Codehighlighter1_793_822_Open_Image.style.display='inline'; Codehighlighter1_793_822_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_793_822_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_793_822_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;value</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">unsigned&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;N</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;IsPrime<BR><IMG id=Codehighlighter1_867_931_Open_Image onclick="this.style.display='none'; Codehighlighter1_867_931_Open_Text.style.display='none'; Codehighlighter1_867_931_Closed_Image.style.display='inline'; Codehighlighter1_867_931_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_867_931_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_867_931_Closed_Text.style.display='none'; Codehighlighter1_867_931_Open_Image.style.display='inline'; Codehighlighter1_867_931_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_867_931_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_867_931_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;value</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">TestPrime</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">N,Sqrt</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">N</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">::value</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">::value;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;IsPrime</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_965_994_Open_Image onclick="this.style.display='none'; Codehighlighter1_965_994_Open_Text.style.display='none'; Codehighlighter1_965_994_Closed_Image.style.display='inline'; Codehighlighter1_965_994_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_965_994_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_965_994_Closed_Text.style.display='none'; Codehighlighter1_965_994_Open_Image.style.display='inline'; Codehighlighter1_965_994_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_965_994_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_965_994_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;value</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top>template&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;IsPrime</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;printf(</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">,<IMG src="http://www.cppblog.com/images/dot.gif">);<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;main()<BR><IMG id=Codehighlighter1_1071_1134_Open_Image onclick="this.style.display='none'; Codehighlighter1_1071_1134_Open_Text.style.display='none'; Codehighlighter1_1071_1134_Closed_Image.style.display='inline'; Codehighlighter1_1071_1134_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_1071_1134_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1071_1134_Closed_Text.style.display='none'; Codehighlighter1_1071_1134_Open_Image.style.display='inline'; Codehighlighter1_1071_1134_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_1071_1134_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cppblog.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_1071_1134_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;yes</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">IsPrime</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">123127</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">::value;<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;printf(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">%d\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,yes);<BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><img src ="http://www.cppblog.com/windreamer/aggbug/1536.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/windreamer/" target="_blank">Windreamer Is Not DREAMER</a> 2005-12-05 09:45 <a href="http://www.cppblog.com/windreamer/archive/2005/12/05/1536.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>