锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲中文久久精品无码,欧美一区二区三区久久综,伊人久久大香线蕉AV一区二区http://www.shnenglu.com/windreamer/<b>main(){main(puts(<font color=brown>"Hello,stranger!"</font>));}</b>zh-cnWed, 07 May 2025 01:29:50 GMTWed, 07 May 2025 01:29:50 GMT60[ZZ]Reconciling Garbage Collection with Deterministic Finalization http://www.shnenglu.com/windreamer/archive/2006/03/21/4401.htmlWindreamer Is Not DREAMERWindreamer Is Not DREAMERTue, 21 Mar 2006 02:01:00 GMThttp://www.shnenglu.com/windreamer/archive/2006/03/21/4401.htmlhttp://www.shnenglu.com/windreamer/comments/4401.htmlhttp://www.shnenglu.com/windreamer/archive/2006/03/21/4401.html#Feedback1http://www.shnenglu.com/windreamer/comments/commentRss/4401.htmlhttp://www.shnenglu.com/windreamer/services/trackbacks/4401.html 鍙戜歡浜猴細 Andrei Alexandrescu (See Website For Email) 鏃ユ湡錛?/b> 2006騫?鏈?8鏃?鏄熸湡鍏? 涓嬪崍12鏃?3鍒? 鐢靛瓙閭歡錛? "Andrei Alexandrescu (See Website For Email)" <SeeWebsiteForEm...@erdani.org> 璁哄潧錛? comp.lang.c++.moderated

The recent thread "Can GC be beneficial" was quite beneficial :o) - to
me at least. I've reached a number of conclusions that allow me to
better place the conciliation between garbage collection and
deterministic finalization in the language design space - in C++ and in
general.

The following discussion focuses on C++-centric considerations, with
occasional escapes into "the right thing to do if we could break away
with the past.

Basic Tenets, Constraints, and Desiderata
=========================================

Garbage collection is desirable because:

(1) It automates a routine and error-prone task

(2) Reduces client code

(3) Improves type safety

(3) Can improve performance, particularly in multithreaded environments

On the other hand, C++ idioms based on constructors and destructors,
including, but not limited to, scoped resource management, have shown to
be highly useful. The large applicability of such idioms might actually
be the single most important reason for which C++ programmers shy away
from migrating to a garbage-collected C++ environment.

It follows that a set of principled methods that reconcile C++-style
programming based on object lifetime, with garbage collection, would be
highly desirable for fully exploiting garbage collection's advantages
within C++. This article discusses the challenges and to suggests
possible designs to address the challenges.

The constraints include compatibility with existing C++ code and styles
of coding, a preference for type safety at least when it doesn't
adversely incur a performance hit, and the functioning of today's
garbage collection algorithms.

A Causal Design
===============

Claim #1: The lifetime management of objects of a class is a decision of
the class implementer, not of the class user.

In support of this claim we come with the following examples:

a) A class such as complex<double> is oblivious to destruction
timeliness because it does not allocate scarce resource that need timely
release;

b) A class such as string doesn't need to worry about destruction
timeliness within a GC (Garbage Collected) environment;

c) A class such as temporary_file does need to worry about destruction
timeliness because it allocates scarce resources that transcend both the
lifetime of the object (a file handle) and the lifetime of the program
(the file on disk that presumably temporary_file needs to delete after
usage).

In all of these examples, the context in which the objects are used is
largely irrelevant (barring ill-designed types that employ logical
coupling to do entirely different actions depending on their state).
There is, therefore, a strong argument that the implementer of a class
decides entirely what the destruction regime of the class shall be. This
claim will guide design considerations below.

We'll therefore assume a C++ extension that allows a class definition to
include its destruction regime:

// 聽garbage聽collected聽
class聽[collected]聽Widget聽{...};聽
//聽deterministically聽destroyed聽
class聽[deterministic]聽Midget聽{...};聽


These two possible choices could be naturally complemented by the other
allowed storage classes of a class:

// 聽garbage聽collected聽or聽on聽stack聽
聽聽
class聽[collected,聽auto]聽Widget聽{...};聽
//聽deterministically聽destroyed,聽stack,聽or聽static聽storage聽
聽聽
class聽[deterministic,聽auto,聽static]聽Midget聽{...};聽

It is illegal, however, that a class specifies both collected and
deterministic regime:

// 聽illegal聽
聽聽
class聽[collected,聽deterministic]聽Wrong聽{...};聽


Claim #2: Collected types cannot define a destruction-time action.

This proposal makes this claim in wake of negative experience with
Java's finalizers.

Claim #3: Collected types can transitively only embed fields of
collected types (or pointers thereof of any depth), and can only derive
from such types.

If a collected type would have a field of a non-collected type, that
type could not be destroyed (as per Claim #2).

If a collected type would have a field of pointer to a non-collected
type, one of two things happens:

a) A dangling pointer access might occur;

b) The resource is kept alive indeterminately and as such cannot be
destroyed (as per claim #2).

If a collected type would have a field of pointer to pointer to (notice
the double indirection) deterministic type, inevitably that pointer's
destination would have to be somehow accessible to the garbage-collected
object. This implies that at the some place in the points-to chain, a
"jump" must exist from the collected realm to the uncollected realm (be
it automatic, static, or deterministic) that would trigger either
post-destruction access, or would prevent the destructor to be called.

Design fork #1: Weak pointers could be supported. A collected type could
hold fields of type weak pointer to non-collected types. The weak
pointers are tracked and are zeroed automatically during destruction of
the resource that they point to. Further dereference attempts accesses
from the collected realm become hard errors.

Claim #4: Deterministic types must track all pointers to their
respective objects (via a precise mechanism such as reference counting
or reference linking).

If deterministic types did allow untracked pointer copying, then
post-destruction access via dangling pointers might occur. The recent
discussion in the thread "Can GC be beneficial" has shown that it is
undesirable to define post-destruction access, and it's best to leave it
as a hard run-time error.

Design branch #2: For type safety reasons, disallow type-erasing
conversions from/to pointers to deterministic types:

聽聽聽
聽聽聽class聽[deterministic]聽Widget聽{...};聽
聽聽聽Widget聽
*聽p聽=new聽Widget;聽
聽聽聽void*聽p1聽=聽p;聽//聽error聽
聽聽聽
p聽=聽static_cast<Widget聽*>(p1);聽//聽error,聽too聽

Or: For compatibility reasons, allow type-erasing conversion and incur
the risk of dangling pointer access.

Design branch #3: For purpose of having a type that stands in as a
pointer to any deterministic type (a sort of "deterministic void*"), all
deterministic classes could be thought as (or required to) inherit a
class std::deterministic.

Design branch #3.1: std::deterministic may or may not define virtuals,
and as such confines or not all deterministic classes to have virtuals
(and be suitable for dynamic_cast among other things).

Claim #5: When an object of deterministic type is constructed in
automatic or static storage, its destructor will automatically issue a
hard error if there are any outstanding pointers to it (e.g., the
reference count is greater than one).

If that didn't happen, dangling accesses to expired stack variables
might occur:

聽class聽[deterministic]聽Widget聽{...};聽
聽Widget聽
*聽p;聽
int聽Fun()聽{聽
聽聽聽聽Widget聽w;聽
聽聽聽聽p聽
=&w;聽
聽聽聽聽
//聽hard聽runtime聽error聽upon聽exiting聽this聽scope聽



}



Discussion of the basic design
==============================

The desiderata set up and the constraints of the current C++ language
created a causal chain that narrowly guided the possible design of an
integrated garbage collection + deterministic destruction in C++:

* The class author decides whether the class is deterministic or garbage
collected

* As a natural extension, the class author can decide whether objects of
that type are allowed to sit on the stack or in static storage. (The
regime of automatic and static storage will be discussed below.)

* Depending on whether a type is deterministic versus collected, the
compiler generates different code for copying pointers to the object.
Basically the compiler automates usage of smart pointers, a
widely-followed semiautomatic discipline in C++.

* The heap is conceptually segregated into two realms. You can hold
unrestricted pointers to objects in the garbage-collected realm, but the
garbage-collected realm cannot hold pointers outside of itself.

* The operations allowed on pointers to deterministic objects are
restricted.

Regime of Automatic Storage
===========================

Claim 6: Pointers to either deterministic or collected objects that are
actually stack allocated should not escape the scope in which their
pointee object exists.

This obvious claim prompts a search in look for an efficient solution to
a class of problems. Here is an example:

聽class聽[auto,聽collected]聽Widget聽{...};聽
void聽Midgetize(Widget聽&聽obj)聽{聽
聽聽聽聽obj.Midgetize();聽


}



void聽Foo()聽{聽
聽聽聽聽Widget聽giantWidget;聽
聽聽聽聽Midgetize(giantWidget);聽


}



To make the example above work, Foo is forced to heap-allocate the
Widget object even though the Midgetize function works on it
transitorily and stack allocation would suffice.

To address this problem a pointer/reference modifier, "auto", can be
defined. Its semantics allow only "downward copying": an
pointer/reference to auto can only be copied to lesser scope, never to
object of larger scope. Examples:

void聽foo()聽{聽
聽聽聽聽Widget聽w;聽
聽聽聽聽Widget聽
*auto聽p1聽=&w1;聽//聽fine,聽p1聽has聽lesser聽scope聽
聽聽聽聽{聽
聽聽聽聽聽聽Widget聽
*auto聽p2聽=&w;聽//聽fine聽
聽聽聽聽聽聽p2聽=聽p1;聽//聽fine聽
聽聽聽聽聽聽p1聽=聽p2;聽//聽error!聽Escaping聽assignment!聽
聽聽聽聽}




}



Then the example above can be made modularly typesafe and efficient like
this:

class聽[auto,聽collected]聽Widget聽{...};聽
void聽Midgetize(Widget聽&auto聽obj)聽{聽
聽聽聽聽obj.Midgetize();聽


}



void聽Foo()聽{聽
聽聽聽聽Widget聽giantWidget;聽
聽聽聽聽Midgetize(giantWidget);聽聽
//聽fine聽


}


Claim #6: "auto"-modified pointers cannot be initialized or assigned
from heap-allocated deterministic objects.

If "auto"-modified pointers manipulated the reference count, their
efficiency advantage would be lost. If they didn't, a type-unsafe
situation can easily occur.

Does operator delete still exist?
=================================

For collected objects, delete is inoperant, as is for static or
automatic objects. On a heap-allocated deterministic object, delete can
simply check if the reference count is 1, and if so, reassign zero to
the pointer. If the reference count is greater than one, issue a hard 聽
error.

Note that this makes delete entirely secure. There is no way to have a
working program that issues a dangling access after delete has been 聽
invoked.

Regime of Static Storage
========================

Static storage has the peculiarity that it can easily engender
post-destruction access. This is because the order of module
initialization is not defined, and therefore cross-module dependencies
among objects of static duration are problematic.

This article delays discussion of the regime of static storage.
Hopefully with help from the community, a workable solution to the
cross-module initialization would ensue.

Templates
=========

Claim #7: The collection regime of any type must be accessible during
compilation to templated code.

Here's a simple question: is vector<T> deterministic or collected?

If it were collected, it couldn't hold deterministic types (because at
the end of the day vector<T> must embed a T*). If it were deterministic,
collected types couldn't hold vectors of pointers to collected types,
which would be a major and gratuitous restriction.

So the right answer is: vector<T> has the same regime as T.

template聽<class聽T,聽class聽A>
class聽[T::collection_regime]聽vector聽{聽//聽or聽some聽other聽syntax聽
聽聽聽...聽

}
;聽


The New World: How Does it Look Like?
=====================================

After this design almost happening as a natural consequence of an
initial set of constraints, the natural question arises: how would
programs look like in a C++ with these amenities?

Below are some considerations:

* Pointer arithmetic, unions, and casts must be reconsidered (a source
of unsafety not thoroughly discussed)

* Most types would be [collected]. Only a minority of types, those that
manage non-memory resources, would live in the deterministic realm.

* Efficiency of the system will not degrade compared to today's C++. The
reduced need for reference-counted resources would allow free and fast
pointer copying for many objects; the minority that need care in
lifetime management will stay tracked by the compiler, the way they
likely were manipulated (by hand) anyway.

* Given that the compiler can apply advanced analysis to eliminate
reference count manipulation in many cases, it is likely that the
quality of built-in reference counting would be superior to
manually-implemented reference counting, and on a par with advanced
manual careful manipulation of a mix of raw and smart pointers.

----------------------

Whew! Please send any comments you have to this group. Thanks!

Andrei

聽 聽 聽 [ See http://www.gotw.ca/resources/clcm.htm for info about ]
聽 聽 聽 [ comp.lang.c++.moderated. 聽 聽First time posters: Do this! ]



]]>
[TAOCP鏉傝皥]鎴戠殑鎵捐尙淇℃湁浜嗗洖闊斥︹?/title><link>http://www.shnenglu.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.shnenglu.com/windreamer/archive/2005/12/16/1814.html</guid><wfw:comment>http://www.shnenglu.com/windreamer/comments/1814.html</wfw:comment><comments>http://www.shnenglu.com/windreamer/archive/2005/12/16/1814.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/windreamer/comments/commentRss/1814.html</wfw:commentRss><trackback:ping>http://www.shnenglu.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>   <BR><SPAN id=_user_mam@theory.stanford.edu>Maggie McLoughlin</SPAN> <FONT color=#00681c><mam@theory.stanford.edu></FONT> to Windreamer<BR><BR></P> <div class="kwuwowk" 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 <= j <= n,<BR>you don't have to do anything.<BR><BR>Thanks for your interest in my book! -- Don Knuth<BR></DIV></BLOCKQUOTE> <HR> 鍛靛懙錛屽師鏉ユ槸鎴戝勾灝戞棤鐭ヤ簡錛屽啀嬈¤禐涓涓婯nuth鐖風埛鍐欎功鐨勭簿鑷?img src ="http://www.shnenglu.com/windreamer/aggbug/1814.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/windreamer/" target="_blank">Windreamer Is Not DREAMER</a> 2005-12-16 10:05 <a href="http://www.shnenglu.com/windreamer/archive/2005/12/16/1814.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>[TAOCP鏉傝皥]絎竴澶╋紝絎竴绔犵涓鑺傦紝涓涓柊寮濮?.....http://www.shnenglu.com/windreamer/archive/2005/12/12/1703.htmlWindreamer Is Not DREAMERWindreamer Is Not DREAMERMon, 12 Dec 2005 13:48:00 GMThttp://www.shnenglu.com/windreamer/archive/2005/12/12/1703.htmlhttp://www.shnenglu.com/windreamer/comments/1703.htmlhttp://www.shnenglu.com/windreamer/archive/2005/12/12/1703.html#Feedback4http://www.shnenglu.com/windreamer/comments/commentRss/1703.htmlhttp://www.shnenglu.com/windreamer/services/trackbacks/1703.html

瑕佽鐨勮瘽濂藉錛屽垪涓彁綰插厛


TAOCP鍒濊鎰熷彈

        銆奣he Art of Computer Programming銆?/STRONG>鐨勭涓鍗?澶х悊鐭寵姳綰圭殑灝佺毊,鎷垮湪鎵嬮噷娌夌敻鐢哥殑,榪欓儴涔︾粰鎴戠殑絎竴鍗拌薄灝辨槸榪欐牱--"鍘氶噸"--甯︽湁鐫紲炵鎰熷拰鍘嗗彶鎰熴?BR>
        鍏跺疄榪欓儴涔︾殑涓枃鐗堝墠璦,鎴戞棭灝辨湁騫告嫓璇昏繃,涓嶈繃鍜岃嫳鏂囧師鏂囩浉姣旇緝,鍦ㄤ腑鏂囩炕璇戠殑鍛抽亾鐪熺殑鏄樊浜嗗緢澶氾紝鎴戣寰楀彧鏈夎鍘熸枃鎵嶈兘鎰熷埌Knuth鐣ュ甫璇欒皭鐨勮屽張鍚屾槸涓嶆槸涓ヨ皚鐨勯鏍鹼紝浠栧啓鏂囩珷鐨勯鏍煎叾瀹炵湡鐨勬尯澶╅┈琛岀┖鐨勶紝浠庡啓紼嬪簭鎵埌鍋氶キ錛屼粠綆楁硶榪欎釜璇嶈亰璧鳳紝榪界潃榪欎釜璇嶇殑鏉ュ巻錛岀珶鐒惰繕甯﹀嚭浜嗚幈甯冨凹鑼紵鐪熸檿錛屽紑鍙ョ帺絎戯紝Knuth緇濆鏄偅縐嶈侀〗绔ュ瀷鐨勪漢鐗╋紝浠栬繖鏈功杈懼埌濡傛鍘氬害浼拌姝ょ被"搴熻瘽"鍔熶笉鍙病銆?BR>
        浠嶢lgorithm鍒癊uclid's Algorithm涔熷氨鏄垜浠啛鎮夌殑杈楄漿鐩擱櫎姹傛渶澶у叕綰︽暟娉曪紝鎴戣繖涓畻娉曞皬鐧藉紑濮嬭繘鍏ヤ簡浠栨墦寮鐨勭畻娉曚笘鐣?.....

        Knuth琛屾枃寰堝枩嬈㈡瘮杈冦佹瘮鍠匯佸姣旓紝榪欒璇昏呯湅璧鋒潵寰堣交鏉炬剦鎮︼紝涓嶈繃褰撲粬鐪熺殑鐜╄搗鏁板鏉ワ紝鎴戝氨鏈夌偣鍚冧笉娑堜簡錛屾渶鍚庨潰瀵圭畻娉曠殑涓涓艦寮忓寲鎻忚堪錛屾秷鑰椾簡鎴戜笉灝戠簿鍔涳紝涓嶈繃鐩墠鐪嬫潵榪樻槸澶ц嚧鏄庣櫧浜?IMG height=20 src="http://www.shnenglu.com/Emoticons/QQ/14.gif" width=20 border=0>

         鎬諱箣錛岃繖鏈洓鍚嶄箣涓嬬殑涔︼紝涔熺殑紜湁寰堝鐙埌鐨勫湴鏂癸紝浣滀負璁$畻鏈虹瀛﹂鍩熺殑鍙茶瘲錛屽畠緇欐垜鐨勭涓鍗拌薄鐨勭‘寰堟銆傚笇鏈涙垜鑳藉潥鎸佺潃鐪嬩笅鍘伙紝浠庝腑鍚告敹钀ュ吇銆?BR>



浠婂ぉ鐨勬敹鑾?/STRONG>

           铏界劧鍙湅浜嗕竴鑺傦紝涓嶈繃涔熸秷鑰椾簡鎴戜笉灝戠殑鏃墮棿鍜岀簿鍔涳紙鐪嬫潵鍒殑涓浜涗簨鎯呬篃涓嶈兘澶借錛屼篃瑕佹姄绱т簡錛?BR>
            浠婂ぉ鐨勬敹鑾峰緢澶氾紝棣栧厛瀵圭畻娉曡繖涓悕璇嶆湁浜嗘洿澶氫竴浜涚殑鎰熸ц璇嗭紝Knuth鎻愬嚭鐨勨滄湁闄愩佹槑紜畾涔夈佹湁杈撳叆銆佹湁杈撳嚭銆佹湁鏁堢巼鈥濊繖鍑犱釜鍘熷垯鎬葷粨寰楃湡鏄笉閿欙紝灝ゅ叾鏈鍓嶉潰鐨勪袱鐐瑰拰鏁堢巼闂錛屽線寰鏋勬垚浜嗗緢澶氬鏉傜殑闂錛岃憲鍚嶇殑鍥劇伒鏈哄仠鏈洪棶棰樺ぇ姒傚氨鏄湪璇磋繖涓棶棰樺惂鈥︹?BR>
            鍙﹀瀵逛簬杈楄漿鐩擱櫎娉曠殑涓浜涙暟瀛︿笂鐨勬帹瀵間篃緇欎簡鎴戜笉閿欑殑鎰熻錛岃櫧鐒朵功涓婃病鏈夋槑紜殑緇欎竴涓弗鏍肩殑璇佹槑錛屼絾鏄牴鎹粬鐨勫彊榪版垜椹笂灝變綋浼氬埌浜嗙敤姣旇緝涓ユ牸鐨勬柟娉曞浣曞啓榪欎釜璇佹槑錛屼互鍙婅繖涓瘉鏄庣殑鍏抽敭鐐癸紙鎴戣寰楄瘉鏄庝腑鍏跺疄鐢ㄥ埌浜嗛氳繃鍙屽寘鍚潵浜夌浉絳夌殑鎵嬫硶錛岃繖涓槸鍏抽敭錛?BR>
            綆楁硶鐨勫艦寮忓寲鎻忚堪搴旇搗浜嗘垜澶х殑鍏磋叮錛屽洖鏉ョ殑璺笂鎯籌紝璨屼技榪欎釜濂藉儚褰㈡垚浜嗘煇縐嶆暟瀛︾粨鏋勶紝鑰屽叾涓婄殑f鏄犲皠錛屾瀯鎴愪簡鏌愮浠f暟緇撴瀯錛屾病鏈変粩緇嗘兂榪囷紝涓嶈繃濂藉儚鏄繖鏍峰瓙鐨勫摝錛屾垜瑙夊緱璨屼技綆楁硶鐨勬湰璐ㄥ氨鏄煇縐嶈嚜鍔ㄧ姸鎬佹満錛屽彧涓嶈繃涓嶄竴瀹氭槸鏈夐檺鐘舵佺殑鍚э紝鑷沖皯浠庝粬鐨勬剰鎬濅笂鐪嬫槸榪欐牱鐨?BR>
            寮濮嬫病鏈夌悊瑙g浜屼釜錛屽姞涓婁簡鏁堢巼綰︽潫鐨勭殑褰㈠紡鍖栬〃杈炬柟娉曠殑鎰忔濓紝鍚庢潵鑺變簡鐐規椂闂寸湅浜嗕笅Ex1.1.8,鎴戣寰楁垜浼間箮鏄庣櫧浜嗙偣

鎴戣涓篍x1.1.8鏄繖鏍風殑涓涓姸鎬佽〃

            

j Theta_j Phi_j a_j b_j
0 a a 5 1
1 ab c 3 2
2 bc cb 1 2
3 b a 4 3
4 c b 0 4
5 c c 5 5

        涓轟簡楠岃瘉錛屾垜鍐欎簡涓畝鍗曠殑紼嬪簭鏉ヨ瘯楠屾垜鐨勭姸鎬佽〃錛堢湡鏄笉琛屼簡錛屽ソ澶氫笢瑗胯緲葷湅鎵嬪唽錛屽啓紼嬪簭鐨勯熷害鎬繪槸涓婁笉鏉ワ級

 1#include    <iostream>
 2#include    <string>
 3
 4using namespace std;
 5int main ( int argc, char *argv[] )
 6{
 7    //                   0,     1,     2,     3,     4,     5
 8    string theta[]={   "a",  "ab",  "cb",      "b",   "c",   "c"};
 9    string phi  []={   "a",   "c",  "bc",    "a",   "b",   "c"};
10    int    a    []={     5,     3,     1,     4,     0,     5};
11    int    b    []={     1,     2,     2,     3,     4,     5};
12
13    int j=0;
14    int i=0;
15    string stat;
16    getline (cin,stat);
17    while(true)
18    {
19        unsigned int loc=stat.find(theta[j],0);
20        if (loc==string::npos)
21        {
22            j=a[j];
23        }

24        else
25        {
26            string temp=stat.substr(0,loc)+phi[j]+stat.substr(loc+theta[j].length());
27            stat=temp;
28            j=b[j];
29        }

30        cout<<i++<<":\tj("<<j<<")\tloc("<<loc<<")\t"<<stat<<endl;
31        cin.get();
32    }

33    return EXIT_SUCCESS;
34}
                /* ----------  end of function main  ---------- */
35


         鏈鍚庝竴瀹氳鎻愮殑鏄紝鎴戝ソ鍍忓彂鐜頒簡涔﹂噷鐨勪竴澶勫皬Bug錛岃屼笖濂藉儚瀹樻柟緗戠珯閲岀殑Errata閲岄潰娌℃湁榪欎釜錛堜腑鏂囩増鍚屾牱鏈夎繖涓棶棰橈級錛屾垜宸茬粡鍐欎俊緇橩nuth浜嗭紝甯屾湜鎴戞槸鐪熺殑鎵懼埌浜嗕竴涓病浜哄彂鐜扮殑Bug鍟婏紙鍏跺疄鎴戠煡閬撹繖涓笉鍙兘錛?BR>



鍏充簬Galgo搴撶殑"鐬庢兂"

         蹇靛彣鍋氫竴涓硾鍨嬬殑綆楁硶搴撳凡緇忔湁濂介暱鏃墮棿浜嗭紝鎴戣寰楄繖涓簨鎯呬笌鍏朵竴鐩磋繖涔圷Y錛岃繕涓嶅楂樺叴浜嗗氨鍐欎竴鐐癸紝涓嶉珮鍏達紝灝辨墧鐫,

         鍏跺疄錛岃繖涓笘鐣屾槸涓嶇己娉涘瀷綆楁硶搴撶殑錛孲TL錛孊oost錛孊litz++涓殑娉涘瀷綆楁硶寰堝叏闈簡錛屾垜鐨勮鍒掓槸鎶婁粬浠腑闂寸己灝戠殑閮ㄥ垎琛ヨ搗鏉ワ紝涓嶈兘浜掓搷浣滅殑鍦版柟綺樺悎璧鋒潵錛屽啀鏈夊氨鏄鍔犲MetaProgramming鐨勬敮鎸?BR>         鍛靛懙錛屽簲璇ヨ繕綆楁槸涓涓瘮杈冮泟浼熺殑璁″垝鍚?BR>         鎴戝笇鏈涜繖濂楀簱鑳藉敖鍙兘鐨勯珮鏁堢巼銆佸鏄撲嬌鐢ㄣ佸悓浜嬩繚璇佸畨鍏紝鐞嗘兂鐨勫鍦版槸鑳藉浠f浛ACM闆嗚闃熶嬌鐢ㄧ殑妯″潡

         鐩墠鎴戠殑璁炬兂鏄暣涓簱鏀懼湪Galgo榪欎釜namespace閲岋紝榪欎釜namespace鍒嗕負涓や釜瀛恘amespace錛屽垎鍒槸娉涘瀷綆楁硶Generic鍜屽厓緙栫▼綆楁硶Meta

          鎴戣寰楄繖鏍蜂竴涓簱鐨勫緩绔嬩笌緇存姢錛屼換閲嶈岄亾榪滀笉璇達紝娌″噯鍓嶄漢宸茬粡浣滆繃360閬嶄簡錛屼笉榪囨病鍏崇郴錛屾潈褰撳ū涔愪簡銆?BR>


First Step鈥斺擡uclid GCD鐨勪竴涓疄鐜?


           涓嶈浠涔堝簾璇濅簡錛屽厛璐翠唬鐮侊細
 1//-------------------------------BEGIN:GAlgo_Euclid_GCD.hpp--------------------------//
 2#ifndef _GAlgo_Euclid_GCD_H_
 3#define _GAlgo_Euclid_GCD_H_
 4namespace GAlgo
 5{
 6    namespace Generic
 7    {
 8        template <typename T>
 9        T Euclid_GCD(const T& a,const T& b)
10        {
11            return ((a%b)==0)?b:Euclid_GCD(b,a%b);
12        }

13    }

14    namespace Meta
15    {
16        template <int A,int B>
17        struct Euclid_GCD
18        {
19            static const int value=Euclid_GCD<B,A%B>::value;
20        }
;
21
22        template <int A>
23        struct Euclid_GCD<A,0>
24        {
25            static const int value=A;
26        }
;
27    }

28}

29#endif
30
31//-------------------------------END:GAlgo_Euclid_GCD.hpp--------------------------//

         搴旇娌′粈涔堝ソ璇寸殑錛屾瘮杈冧腑瑙勪腑鐭╋紝甯歌鎵嬫硶錛屼笉榪囨牴鎹甌AOCP涓婄殑璇存硶錛屽彲鑳藉湪鏌愪簺m錛宯鐨勫彇鍊間笂闇瑕佸緢澶氶噸鐨勯掑綊榪欐椂鍊橫eta鐨勬柟娉曞彲鑳戒細閬囧埌鍥伴毦錛堝叾瀹炵涓縐嶄篃鏈夎繍琛屾椂鍫嗘爤婧㈠嚭鐨勫嵄闄╋級錛屾墍浠ヨ鈥︹﹁浠涔堝ソ鍛紝灝辮繖鏍蜂簡

涓嬮潰鏄釜綆鍗曠殑嫻嬭瘯
 1#include "GAlgo_Euclid_GCD.hpp" 
 2#include <iostream>
 3using namespace std;
 4int main()
 5{
 6    cout<<GAlgo::Generic::Euclid_GCD(6,9)<<endl;
 7    cout<<GAlgo::Meta::Euclid_GCD<6,9>::value<<endl;
 8    return 0;
 9}

10



涓漢瑙夊緱浠婂悗鏈夌爺絀朵環鍊肩殑鏂瑰悜

         鎴戣寰楀浜庣畻娉曟弿榪板拰鍥劇伒鏈恒佹湁闄愮姸鎬佹満銆佷互鍙婇殣闅愮害綰︽垜鐪嬪埌鐨勯┈灝旂澶殑鏌愪簺宸ヤ綔錛堥┈灝旂澶摼錛変箣闂寸殑鍏崇郴娣卞叆鎸栨帢涓涓嬪簲璇ヤ細鏈変笉灝戞敹鑾鳳紝閭d釜鎴戝榪欎釜闂鍙兘浼氭湁涓涓暟瀛︾粨鏋勭殑鐚滄兂浼拌涔熷彲鑳藉彲浠ュ湪榪欎釜鏂瑰悜涓婅瘉瀹炴垨璇佷吉鈥︹?BR>         紿佺劧鎯沖幓鍚戝伓鍍忛粍鍏嗛晣璇鋒暀涓涓嬧︹﹁繕鏄瓑鎴戞妸鑳嗗瓙鍏堢粌澶у啀鍘誨惂鈥︹?img src ="http://www.shnenglu.com/windreamer/aggbug/1703.html" width = "1" height = "1" />

]]>
[涔﹁瘎]銆奀++Templates銆?/title><link>http://www.shnenglu.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.shnenglu.com/windreamer/archive/2005/12/10/1657.html</guid><wfw:comment>http://www.shnenglu.com/windreamer/comments/1657.html</wfw:comment><comments>http://www.shnenglu.com/windreamer/archive/2005/12/10/1657.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.shnenglu.com/windreamer/comments/commentRss/1657.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/windreamer/services/trackbacks/1657.html</trackback:ping><description><![CDATA[<P>緇堜簬鏃犺亰鍒版潵鍐欎功璇勶紝鏈榪戠殑欏圭洰涓鐩撮兘娌″拰C++鏈変粈涔堝叧緋伙紝涓嶈繃鐪嬬殑涔﹀嵈閮芥槸C++鏂歸潰鐨勶紝鑰屾渶榪戠湅鍒扮殑鍑犳湰涔︿腑鎰熻鏈濂界殑鑾繃浜庤繖鏈奀++ Templates銆?BR><BR>Nicolai M. Josuttis鐨勪功鎴戝緢鍠滄錛屼粠浠栫殑閭f湰銆奣he C++ Standard Template Library銆嬪氨鐪嬪嚭浜嗕粬寰堝鐙壒鐨勯鏍鹼紝浠ゆ垜鐖變笉閲婃墜錛屾墍浠ヨ繖鏈奀++ Template銆?nbsp;  涔熻繘鍏ヤ簡鎴戠殑蹇呯湅涔﹀崟銆傜矖璇諱箣鍚庯紝鎰熻鏁存湰涔︾粷瀵瑰皢鎴愪負C++娉涘瀷棰嗗煙鐨勫湥緇忕駭钁椾綔<BR><BR> <OL> <LI>榪欐湰涔﹁搴﹂夊緱寰堝ソ錛屽叏涔﹀垎涓変釜閮ㄥ垎錛屽垎鍒粙緇嶆ā鏉垮熀紜銆佹ā鐗堢殑緙栬瘧鍣ㄥ疄鐜般佹ā鏉跨殑楂樼駭鎶宸э紝涓変釜閮ㄥ垎鐩歌緟鐩告垚銆佺浉浜掔収搴旓紝鐢辨祬鍏ユ繁鑰屽張鑷劧鑰岀劧錛岃繕鏂逛究鍒嗗紑闃呰錛堟瘮濡傛垜灝遍噸鐐圭湅浜嗙涓絎笁閮ㄥ垎錛屾ā鐗堝疄鐜拌鎴戠暐榪囦簡<IMG height=19 src="http://www.shnenglu.com/Emoticons/72_72.gif" width=19 border=0>錛夊嵈鍙堝叏闈㈣鐩栦簡榪欎竴棰嗗煙<BR> <LI>榪欐湰涔﹁嫳鏂囧緢嫻呮樉錛堟瘮銆奙odern C++ Design銆嬫祬鏄句簡涓嶇煡澶氬皯鍊嶏級錛岃璦涓ヨ皚鑰屽張涓嶆櫐娑╋紝灝ゅ叾瑕佽禐鐨勫氨鏄簾璇濆挨鍏跺湴灝戯紒<BR> <LI>绔犺妭瀹夋帓寰堝悎鐞嗭紝寰堟柟鍒綔涓哄伐鍏蜂功搴旀ユ煡闃咃紙銆奀++STL銆嬪氨鏈夎繖涓紭鐐癸紝涓庤繖鏈功縐戝瀹?宸ョ▼甯堢殑緇勫悎涓嶆棤鍏崇郴錛?BR> <LI>涔︿腑濂藉鎶鏈紝鎴戞槸闂繪墍鏈椈錛屾儕涓哄ぉ浜猴紝灝ゅ叾絎笁閮ㄥ垎錛屽彲浠ョ畻寰椾笂鐪艱姳緙貢錛岃屼笖緇欏嚭鐨勫疄鐜版劅瑙夋棦絎﹀悎鏍囧噯銆佸疄鐢ㄣ佽屼笖娌℃湁鐐妧鐨勬垚鍒?/LI></OL> <P>鍚岀被涔︾睄鎹垜鎵鐭ユ病鏈夊彲浠ヨ揪鍒拌繖涓珮搴︾殑錛屽ぇ閮ㄥ垎C++娉涘瀷鏂歸潰鐨勪笓钁楀彧灞闄愪簬鎬庝箞鐢⊿TL錛屽皢妯℃澘鍩虹鐨勪功錛屼篃浠呴檺浜庢渶琛ㄩ潰鐨勮娉曪紝鍍忔ā鐗堝弬鏁版帹瀵艱繖縐嶉棶棰橀矞鏈夋秹鍙婏紝鏇翠笉鐢ㄦ彁鍏充簬Metaprogramming錛岃繖鏈功鍦g粡鐨勫湴浣嶄及璁″悗浜轟篃鏄毦浠ヤ紒鍙婁簡銆?/P> <P>涓嬮潰鏄垜鐪嬩功鏃剁敾涓嬫潵鐨勪竴浜涜寰楄嚜宸卞鉤鏃跺簲璇ユ敞鎰忕殑鍦版柟錛屾斁鍦ㄨ繖閲屽仛澶囧繕濂戒簡<BR><BR></P> <OL> <LI>(P12) [Argument Deducion] If we pass two <STRONG>ints</STRONG> to the parameter type <STRONG>T const&  </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.shnenglu.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">template </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">typename T</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>inline T </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000"> max (T </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000"> a,T </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000"> b);<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><IMG src="http://www.shnenglu.com/images/dot.gif"><BR><IMG src="http://www.shnenglu.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 is int for both arguments</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.shnenglu.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 T is int,second T is 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  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.shnenglu.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">template </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">typename T,</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> VAL</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>T addValue (T </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000"> 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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_54_73_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> x</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">VAL<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>std::transform(source.begin(),source.end(),</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">start and end of source</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.shnenglu.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 of destination</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.shnenglu.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">  </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000">))addValue</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">5</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">);</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">operation<BR><IMG src="http://www.shnenglu.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.shnenglu.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">template </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> N</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> printBitset (std::bitset</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">N</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000"> 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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_61_172_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>    std::cout</SPAN><SPAN style="COLOR: #000000"><<</SPAN><SPAN style="COLOR: #000000">bs.to_string</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">,char_traits</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">,allacator</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">();</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">ERROR:can't recogonize the template</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>template </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> N</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> printBitset (std::bitset</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">N</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000"> 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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_236_323_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>    std::cout</SPAN><SPAN style="COLOR: #000000"><<</SPAN><SPAN style="COLOR: #000000">bs.template to_string</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">,char_traits</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">,allacator</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">></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.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN></DIV><BR> <LI>(P45)[Using this->]<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.shnenglu.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">template </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">typename T</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> 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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_33_59_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">:<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> bar();<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>template </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">typename T</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> Derived : Base</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">T</SPAN><SPAN style="COLOR: #000000">></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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_109_191_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">:<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> 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.shnenglu.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.shnenglu.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_138_189_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>        bar();</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">call external bar() or error</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>template </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">typename T</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> Derived : Base</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">T</SPAN><SPAN style="COLOR: #000000">></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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_240_302_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">:<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> 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.shnenglu.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.shnenglu.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_269_300_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">-></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.shnenglu.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV><BR> <LI>鍚屾牱綺懼僵鐨勮繕鏈?P57)[Using String Literals as Arguments for Function Templates]<BR> <LI>浠ゆ垜鎯婂紓鐨凷FINE鎶鏈?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.shnenglu.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">template </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">typename T</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> 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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_37_287_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">:<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>    typedef </SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000"> 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.shnenglu.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.shnenglu.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    typedef </SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000"> </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.shnenglu.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"> a[</SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">];}</SPAN></SPAN><SPAN style="COLOR: #000000"> Two;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>    template </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">typename C</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> One test (</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.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top>    template </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">typename C</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> Two test(<IMG src="http://www.shnenglu.com/images/dot.gif">);<BR><IMG src="http://www.shnenglu.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.shnenglu.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.shnenglu.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">enum</SPAN><SPAN style="COLOR: #000000"> </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.shnenglu.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"><</SPAN><SPAN style="COLOR: #000000">T</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">::test</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">T</SPAN><SPAN style="COLOR: #000000">></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.shnenglu.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.shnenglu.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">enum</SPAN><SPAN style="COLOR: #000000"> </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.shnenglu.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.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;</SPAN></DIV></LI></OL><BR>鎬昏岃█涔嬶紝姝や功甯︾粰浜嗘垜鍓嶆墍鏈湁鐨勯槄璇諱韓鍙?.....鎴戜粖騫撮渿鎾煎ぇ濂栦竴瀹氫細鎶曞畠涓紲?img src ="http://www.shnenglu.com/windreamer/aggbug/1657.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/windreamer/" target="_blank">Windreamer Is Not DREAMER</a> 2005-12-10 12:36 <a href="http://www.shnenglu.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.shnenglu.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.shnenglu.com/windreamer/archive/2005/12/05/1536.html</guid><wfw:comment>http://www.shnenglu.com/windreamer/comments/1536.html</wfw:comment><comments>http://www.shnenglu.com/windreamer/archive/2005/12/05/1536.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/windreamer/comments/commentRss/1536.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/windreamer/services/trackbacks/1536.html</trackback:ping><description><![CDATA[涓昏鍠滄浠栫殑璇硶鐫鑹插姛鑳斤紝鐪熺殑寰堟柟渚匡紝RSS絳夋柟闈㈢殑鍔熻兘涔熷緢鍏ㄩ潰......<IMG height=19 src="http://www.shnenglu.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.shnenglu.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.shnenglu.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.shnenglu.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.shnenglu.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.shnenglu.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.shnenglu.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>template</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> Val</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000"> 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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_108_142_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> value </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> Val ;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>template</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #0000ff">bool</SPAN><SPAN style="COLOR: #000000"> flag, typename T, typename U</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000"> 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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_203_224_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top> typedef T Result;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>template</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">typename T, typename U</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000"> Select</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #0000ff">false</SPAN><SPAN style="COLOR: #000000">, T, U</SPAN><SPAN style="COLOR: #000000">></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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_288_309_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top> typedef U Result;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>template </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">unsigned </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> N,unsigned </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> x</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000"> 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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_369_478_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> value</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">Select</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">((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"><</SPAN><SPAN style="COLOR: #000000">x</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">,FindRoot</SPAN><SPAN style="COLOR: #000000"><</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">></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">::Result::value;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>template </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">unsigned </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> N</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000"> 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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_520_570_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> value</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">FindRoot</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">N,N</SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">::value;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>template </SPAN><SPAN style="COLOR: #000000"><></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000"> Sqrt</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"> ;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>template </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> N,</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> divider</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000"> 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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_650_750_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> value</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">Select</SPAN><SPAN style="COLOR: #000000"><</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"><</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">,TestPrime</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">N,divider</SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">::Result::value;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>template </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> N</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000"> TestPrime</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">N,</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">></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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_793_822_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> value</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>template </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">unsigned </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> N</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000"> 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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_867_931_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> value</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">TestPrime</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">N,Sqrt</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">N</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">::value</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">::value;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>template </SPAN><SPAN style="COLOR: #000000"><></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000"> IsPrime</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">></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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_965_994_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> value</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top>template </SPAN><SPAN style="COLOR: #000000"><></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000"> IsPrime</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> printf(</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">,<IMG src="http://www.shnenglu.com/images/dot.gif">);<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> 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.shnenglu.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.shnenglu.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.shnenglu.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_1071_1134_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> yes</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">IsPrime</SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">123127</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">::value;<BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/InBlock.gif" align=top> 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.shnenglu.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.shnenglu.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><img src ="http://www.shnenglu.com/windreamer/aggbug/1536.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/windreamer/" target="_blank">Windreamer Is Not DREAMER</a> 2005-12-05 09:45 <a href="http://www.shnenglu.com/windreamer/archive/2005/12/05/1536.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://www.shnenglu.com/" title="精品视频久久久久">精品视频久久久久</a> <div class="friend-links"> </div> </div> </footer> <a href="http://www.tianlaiedu.cn" target="_blank">国产激情久久久久影院老熟女免费 </a>| <a href="http://www.fiyhigh.com.cn" target="_blank">国产精品久久久久久福利漫画 </a>| <a href="http://www.vedz.cn" target="_blank">久久亚洲AV永久无码精品</a>| <a href="http://www.duange.com.cn" target="_blank">久久精品中文字幕第23页</a>| <a href="http://www.kwk9605.cn" target="_blank">亚洲欧美日韩久久精品</a>| <a href="http://www.sxxnjy.cn" target="_blank">99久久无码一区人妻a黑</a>| <a href="http://www.heqiaoluo.cn" target="_blank">久久精品这里只有精99品</a>| <a href="http://www.taoxh.cn" target="_blank">99久久综合国产精品免费</a>| <a href="http://www.t5573.cn" target="_blank">久久免费视频观看</a>| <a href="http://www.rideos.cn" target="_blank">精品久久久久久久国产潘金莲</a>| <a href="http://www.sh-richardmille.cn" target="_blank">久久精品欧美日韩精品</a>| <a href="http://www.popotang.cn" target="_blank">久久久久亚洲AV综合波多野结衣</a>| <a href="http://www.kucunshuo.cn" target="_blank">亚洲AV无码久久精品色欲</a>| <a href="http://www.shcolor.com.cn" target="_blank">九九久久精品无码专区</a>| <a href="http://www.oldoak.net.cn" target="_blank">色偷偷久久一区二区三区</a>| <a href="http://www.shhuguang.com.cn" target="_blank">久久国产精品免费一区二区三区</a>| <a href="http://www.xahjqc.cn" target="_blank">色综合久久无码中文字幕</a>| <a href="http://www.37photo.com.cn" target="_blank">久久综合色之久久综合</a>| <a href="http://www.77ns.cn" target="_blank">精品国产综合区久久久久久 </a>| <a href="http://www.cqhxdj.com.cn" target="_blank">精品久久人人妻人人做精品 </a>| <a href="http://www.gmmk.net.cn" target="_blank">久久久久人妻精品一区三寸蜜桃</a>| <a href="http://www.zhoucheng888.cn" target="_blank">久久这里只有精品首页</a>| <a href="http://www.huoguopot.cn" target="_blank">国产精品va久久久久久久</a>| <a href="http://www.qcbijj.cn" target="_blank">久久不见久久见免费视频7</a>| <a href="http://www.0756400.cn" target="_blank">久久www免费人成看片</a>| <a href="http://www.rainbows.net.cn" target="_blank">狠狠久久综合</a>| <a href="http://www.dykh-tech.cn" target="_blank">久久99精品国产麻豆蜜芽</a>| <a href="http://www.msomso.cn" target="_blank">热久久这里只有精品</a>| <a href="http://www.sqcn.com.cn" target="_blank">久久99国产亚洲高清观看首页</a>| <a href="http://www.97youbei.cn" target="_blank">狠狠色丁香久久婷婷综合</a>| <a href="http://www.forsagecn.cn" target="_blank">久久亚洲精品国产亚洲老地址</a>| <a href="http://www.epuda.cn" target="_blank">久久久精品久久久久久 </a>| <a href="http://www.yunshanhong.cn" target="_blank">久久精品人人做人人爽电影</a>| <a href="http://www.fwjs.net.cn" target="_blank">色综合久久久久综合99</a>| <a href="http://www.iandu.cn" target="_blank">四虎影视久久久免费</a>| <a href="http://www.9258bbs.cn" target="_blank">日韩欧美亚洲综合久久影院Ds</a>| <a href="http://www.5748l.cn" target="_blank">久久精品中文字幕第23页</a>| <a href="http://www.eurocake.com.cn" target="_blank">久久精品这里只有精99品</a>| <a href="http://www.sh-ar.cn" target="_blank">午夜精品久久久内射近拍高清 </a>| <a href="http://www.yf-plastic.com.cn" target="_blank">亚洲人成网亚洲欧洲无码久久</a>| <a href="http://www.jianfeiyaow.cn" target="_blank">久久综合久久综合亚洲</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>