青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

Windreamer Is Not a DREAMER
main(){main(puts("Hello,stranger!"));}

2006年3月21日

發(fā)件人: Andrei Alexandrescu (See Website For Email) ?
日期: 2006年3月18日(星期六) 下午12時13分
電子郵件: "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! ]

posted @ 2006-03-21 10:01 Windreamer Is Not DREAMER 閱讀(634) | 評論 (1)編輯 收藏

2005年12月16日

Is it a mistake in TAOCP  
Maggie McLoughlin <mam@theory.stanford.edu> to Windreamer

Sequences with n=0 are empty. It's important in mathematics
to deal with empty sets and strings etc in a meaningful way.
If n = 0 and you're supposed to do something for 1 <= j <= n,
you don't have to do anything.

Thanks for your interest in my book! -- Don Knuth

呵呵,原來是我年少無知了,再次贊一下Knuth爺爺寫書的精致
posted @ 2005-12-16 10:05 Windreamer Is Not DREAMER 閱讀(595) | 評論 (1)編輯 收藏

2005年12月12日

要說的話好多,列個提綱先


TAOCP初讀感受

        《The Art of Computer Programming》的第一卷,大理石花紋的封皮,拿在手里沉甸甸的,這部書給我的第一印象就是這樣--"厚重"--帶有著神秘感和歷史感。

        其實這部書的中文版前言,我早就有幸拜讀過,不過和英文原文相比較,在中文翻譯的味道真的是差了很多,我覺得只有讀原文才能感到Knuth略帶詼諧的而又同是不是嚴謹?shù)娘L格,他寫文章的風格其實真的挺天馬行空的,從寫程序扯到做飯,從算法這個詞聊起,追著這個詞的來歷,竟然還帶出了萊布尼茨?真暈,開句玩笑,Knuth絕對是那種老頑童型的人物,他這本書達到如此厚度估計此類"廢話"功不可沒。

        從Algorithm到Euclid's Algorithm也就是我們熟悉的輾轉相除求最大公約數(shù)法,我這個算法小白開始進入了他打開的算法世界......

        Knuth行文很喜歡比較、比喻、對比,這讓讀者看起來很輕松愉悅,不過當他真的玩起數(shù)學來,我就有點吃不消了,最后面對算法的一個形式化描述,消耗了我不少精力,不過目前看來還是大致明白了

         總之,這本盛名之下的書,也的確有很多獨到的地方,作為計算機科學領域的史詩,它給我的第一印象的確很棒。希望我能堅持著看下去,從中吸收營養(yǎng)。




今天的收獲

           雖然只看了一節(jié),不過也消耗了我不少的時間和精力(看來別的一些事情也不能太耽誤,也要抓緊了)

            今天的收獲很多,首先對算法這個名詞有了更多一些的感性認識,Knuth提出的“有限、明確定義、有輸入、有輸出、有效率”這幾個原則總結得真是不錯,尤其最前面的兩點和效率問題,往往構成了很多復雜的問題,著名的圖靈機停機問題大概就是在說這個問題吧……

            另外對于輾轉相除法的一些數(shù)學上的推導也給了我不錯的感覺,雖然書上沒有明確的給一個嚴格的證明,但是根據(jù)他的敘述我馬上就體會到了用比較嚴格的方法如何寫這個證明,以及這個證明的關鍵點(我覺得證明中其實用到了通過雙包含來爭相等的手法,這個是關鍵)

            算法的形式化描述應起了我大的興趣,回來的路上想,貌似這個好像形成了某種數(shù)學結構,而其上的f映射,構成了某種代數(shù)結構,沒有仔細想過,不過好像是這樣子的哦,我覺得貌似算法的本質就是某種自動狀態(tài)機,只不過不一定是有限狀態(tài)的吧,至少從他的意思上看是這樣的

            開始沒有理解第二個,加上了效率約束的的形式化表達方法的意思,后來花了點時間看了下Ex1.1.8,我覺得我似乎明白了點

我認為Ex1.1.8是這樣的一個狀態(tài)表

            

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

        為了驗證,我寫了個簡單的程序來試驗我的狀態(tài)表(真是不行了,好多東西要翻看手冊,寫程序的速度總是上不來)

 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


         最后一定要提的是,我好像發(fā)現(xiàn)了書里的一處小Bug,而且好像官方網站里的Errata里面沒有這個(中文版同樣有這個問題),我已經寫信給Knuth了,希望我是真的找到了一個沒人發(fā)現(xiàn)的Bug啊(其實我知道這個不可能)




關于Galgo庫的"瞎想"

         念叨做一個泛型的算法庫已經有好長時間了,我覺得這個事情與其一直這么YY,還不如高興了就寫一點,不高興,就扔著,

         其實,這個世界是不缺泛型算法庫的,STL,Boost,Blitz++中的泛型算法很全面了,我的計劃是把他們中間缺少的部分補起來,不能互操作的地方粘合起來,再有就是增加對MetaProgramming的支持
         呵呵,應該還算是一個比較雄偉的計劃吧
         我希望這套庫能盡可能的高效率、容易使用、同事保證安全,理想的境地是能夠代替ACM集訓隊使用的模塊

         目前我的設想是整個庫放在Galgo這個namespace里,這個namespace分為兩個子namespace,分別是泛型算法Generic和元編程算法Meta

          我覺得這樣一個庫的建立與維護,任重而道遠不說,沒準前人已經作過360遍了,不過沒關系,權當娛樂了。



First Step——Euclid GCD的一個實現(xiàn)


           不說什么廢話了,先貼代碼:
 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--------------------------//

         應該沒什么好說的,比較中規(guī)中矩,常規(guī)手法,不過根據(jù)TAOCP上的說法,可能在某些m,n的取值上需要很多重的遞歸這時候Meta的方法可能會遇到困難(其實第一種也有運行時堆棧溢出的危險),所以說……說什么好呢,就這樣了

下面是個簡單的測試
 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



個人覺得今后有研究價值的方向

         我覺得對于算法描述和圖靈機、有限狀態(tài)機、以及隱隱約約我看到的馬爾科夫的某些工作(馬爾科夫鏈)之間的關系深入挖掘一下應該會有不少收獲,那個我對這個問題可能會有一個數(shù)學結構的猜想估計也可能可以在這個方向上證實或證偽……
         突然想去向偶像黃兆鎮(zhèn)請教一下……還是等我把膽子先練大再去吧……
posted @ 2005-12-12 21:48 Windreamer Is Not DREAMER 閱讀(1467) | 評論 (4)編輯 收藏

2005年12月10日

終于無聊到來寫書評,最近的項目一直都沒和C++有什么關系,不過看的書卻都是C++方面的,而最近看到的幾本書中感覺最好的莫過于這本《C++ Templates》

Nicolai M. Josuttis的書我很喜歡,從他的那本《The C++ Standard Template Library》就看出了他很多獨特的風格,令我愛不釋手,所以這本《C++ Template》   也進入了我的必看書單。粗讀之后,感覺整本書絕對將成為C++泛型領域的圣經級著作

  1. 這本書角度選得很好,全書分三個部分,分別介紹模板基礎、模版的編譯器實現(xiàn)、模板的高級技巧,三個部分相輔相成、相互照應,由淺入深而又自然而然,還方便分開閱讀(比如我就重點看了第一第三部分,模版實現(xiàn)被我略過了)卻又全面覆蓋了這一領域
  2. 這本書英文很淺顯(比《Modern C++ Design》淺顯了不知多少倍),語言嚴謹而又不晦澀,尤其要贊的就是廢話尤其地少!
  3. 章節(jié)安排很合理,很方別作為工具書應急查閱(《C++STL》就有這個優(yōu)點,與這本書科學家+工程師的組合不無關系)
  4. 書中好多技術,我是聞所未聞,驚為天人,尤其第三部分,可以算得上眼花繚亂,而且給出的實現(xiàn)感覺既符合標準、實用、而且沒有炫技的成分

同類書籍據(jù)我所知沒有可以達到這個高度的,大部分C++泛型方面的專著只局限于怎么用STL,將模板基礎的書,也僅限于最表面的語法,像模版參數(shù)推導這種問題鮮有涉及,更不用提關于Metaprogramming,這本書圣經的地位估計后人也是難以企及了。

下面是我看書時畫下來的一些覺得自己平時應該注意的地方,放在這里做備忘好了

  1. (P12) [Argument Deducion] If we pass two ints to the parameter type T const&  the C++ compiler must conclude that T must be int. Note that no automatic type conversion is allowed here,Each T must match exactly.

    template <typename T>
    inline T 
    const& max (T const& a,T const& b);

    max(
    4,7)//OK:T is int for both arguments
    max(4,4.2)//ERROR:first T is int,second T is double

  2. (P13)[Template Parameters] In function templates(unlike class template) no default template arguments can be specified
  3. (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.
  4. (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.
  5. (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

    template <typename T,int VAL>
    T addValue (T 
    const& x)
    {
        
    return x+VAL
    }


    std::transform(source.begin(),source.end(),
    //start and end of source
    dest.begin(),//start of destination
    (int(*)(int  const&))addValue<int,5>);//operation

  6. (P40)[Restrictions for Nontype Template Parameters] 太長了,略過
  7. (P44)[The .template Construct]

    template <int N>
    void printBitset (std::bitset<N> const& bs)
    {
        std::cout
    <<bs.to_string<char,char_traits<char>,allacator<char> >();//ERROR:can't recogonize the template
    }


    template 
    <int N>
    void printBitset (std::bitset<N> const& bs)
    {
        std::cout
    <<bs.template to_string<char,char_traits<char>,allacator<char> >();//OK
    }

  8. (P45)[Using this->]

    template <typename T>
    class Base
    {
    public:
        
    void bar();
    }
    ;

    template 
    <typename T>
    class Derived : Base<T>
    {
    public:
        
    void foo()
        
    {
            bar();
    //call external bar() or error
        }

    }


    template 
    <typename T>
    class Derived : Base<T>
    {
    public:
        
    void foo()
        
    {
            
    this->bar();//OK
        }

    }

  9. 同樣精彩的還有(P57)[Using String Literals as Arguments for Function Templates]
  10. 令我驚異的SFINE技術(substitution-failure-is-not-an-error)

    template <typename T>
    class IsClassT
    {
    private:
        typedef 
    char One;
        typedef 
    struct {char a[2];} Two;
        template 
    <typename C> static One test (int::C*);
        template 
    <typename C> static Two test();
    public:
        
    enum {Yes=sizeof(IsClassT<T>::test<T>(0))==1};
        
    enum {No=!Yes};
    }
    ;

總而言之,此書帶給了我前所未有的閱讀享受......我今年震撼大獎一定會投它一票
posted @ 2005-12-10 12:36 Windreamer Is Not DREAMER 閱讀(652) | 評論 (3)編輯 收藏

2005年12月5日

主要喜歡他的語法著色功能,真的很方便,RSS等方面的功能也很全面......

測試一下:

//////////////////////////////
//Prime.cpp
//////////////////////////////

template
<int Val>
struct IntType
{
 
const static int value = Val ;
}
;
template
<bool flag, typename T, typename U>
struct Select
{
 typedef T Result;
}
;

template
<typename T, typename U>
struct Select<false, T, U>
{
 typedef U Result;
}
;
template 
<unsigned int N,unsigned int x>
struct FindRoot
{
 
const static int value=Select<(N/x)==x||((N/x+x)/2==x),IntType<x>,FindRoot<N,(N/x+x)/2> >::Result::value;
}
;

template 
<unsigned int N>
struct Sqrt
{
 
const static int value=FindRoot<N,N/2>::value;
}
;

template 
<>
struct Sqrt<0> ;

template 
<int N,int divider>
struct TestPrime
{
 
const static int value=Select<(N%divider)==0,IntType<0>,TestPrime<N,divider-1> >::Result::value;
}
;

template 
<int N>
struct TestPrime<N,1>
{
 
const static int value=1;
}
;

template 
<unsigned int N>
struct IsPrime
{
 
const static int value=TestPrime<N,Sqrt<N>::value+1>::value;
}
;

template 
<>
struct IsPrime<2>
{
 
const static int value=1;
}
;

template 
<>
struct IsPrime<1>;

int printf(const char*,);

int main()
{
 
const int yes=IsPrime<123127>::value;
 printf(
"%d\n",yes);
}

posted @ 2005-12-05 09:45 Windreamer Is Not DREAMER 閱讀(391) | 評論 (1)編輯 收藏
僅列出標題  
 
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美一区二区三区在| 欧美在线关看| 亚洲国产一二三| 另类天堂av| 91久久午夜| 亚洲福利视频一区| 欧美日韩精品在线视频| 中文精品99久久国产香蕉| 中文在线资源观看网站视频免费不卡 | 久久国产精品久久久久久久久久| 国产伦精品一区| 久久综合成人精品亚洲另类欧美 | 欧美1区3d| 欧美成年人网| 亚洲免费在线视频一区 二区| 亚洲无亚洲人成网站77777| 国产一区二区福利| 亚洲国产99精品国自产| 欧美色视频一区| 久久国产日韩欧美| 美日韩丰满少妇在线观看| 日韩亚洲国产精品| 亚洲综合清纯丝袜自拍| 国内成人精品2018免费看| 亚洲国产精品va在看黑人| 欧美日韩免费网站| 另类欧美日韩国产在线| 欧美日韩国产大片| 久久先锋资源| 欧美少妇一区| 乱中年女人伦av一区二区| 欧美日韩三级一区二区| 蜜桃久久精品乱码一区二区| 欧美精品激情blacked18| 久久精品国产亚洲精品| 欧美黑人在线观看| 久久视频国产精品免费视频在线| 欧美肥婆bbw| 久久一区二区三区四区| 欧美性片在线观看| 欧美激情亚洲激情| 韩国免费一区| 亚洲影音一区| 在线视频欧美日韩| 久久综合电影| 久久精品一区蜜桃臀影院| 欧美日韩国产成人高清视频| 欧美aaa级| 国产视频久久网| 一区二区三区鲁丝不卡| 亚洲日本无吗高清不卡| 久久久91精品国产| 欧美一区二区精品久久911| 欧美国产亚洲视频| 欧美激情aⅴ一区二区三区| 国内成+人亚洲| 亚洲欧美中文字幕| 午夜精品在线| 欧美三级电影精品| 99re亚洲国产精品| 一本久久综合| 欧美日韩伦理在线| 亚洲精品在线视频| 亚洲美女免费精品视频在线观看| 一区二区国产精品| 久久躁狠狠躁夜夜爽| 在线不卡中文字幕播放| 欧美成人激情在线| 国模 一区 二区 三区| 亚洲欧美变态国产另类| 性视频1819p久久| 国产乱码精品一区二区三区五月婷 | 亚洲精品午夜| 欧美高清在线精品一区| 亚洲黄色成人网| 亚洲精品三级| 欧美精品黄色| 99视频精品全国免费| 亚洲一线二线三线久久久| 欧美视频二区36p| 亚洲一区精品在线| 久久久精品网| 亚洲国产欧美一区二区三区久久| 久久影音先锋| 亚洲精品久久久久中文字幕欢迎你 | 亚洲国产精品t66y| 欧美成人一区二区三区在线观看 | 日韩一区二区精品葵司在线| 亚洲一区二区三区乱码aⅴ蜜桃女| 欧美视频中文在线看| 中文欧美字幕免费| 欧美一区二区三区四区夜夜大片| 国产精品视频免费在线观看| 欧美一级电影久久| 欧美激情视频免费观看| 亚洲午夜一区二区| 激情综合网址| 欧美日韩在线播放三区| 亚洲欧美一区二区视频| 麻豆九一精品爱看视频在线观看免费 | 久久精品主播| 亚洲国产欧美一区二区三区同亚洲| 亚洲精品字幕| 国产三级精品在线不卡| 欧美gay视频| 亚洲欧美日韩成人| 亚洲二区视频在线| 欧美一区二区三区日韩视频| 亚洲国产精品国自产拍av秋霞| 欧美日产在线观看| 久久国产精品久久久久久| 亚洲剧情一区二区| 老司机免费视频久久| 亚洲视频axxx| 91久久久久| 国内视频一区| 国产精品成人一区二区三区夜夜夜| 久久精品99无色码中文字幕| 日韩网站免费观看| 欧美wwwwww| 久久精品一本久久99精品| 亚洲素人在线| 亚洲精品久久久一区二区三区| 国产精品丝袜久久久久久app| 欧美国产欧美亚洲国产日韩mv天天看完整| 亚洲私人影院在线观看| 亚洲福利视频一区| 麻豆视频一区二区| 欧美综合77777色婷婷| 一区二区三区精品视频| 亚洲电影免费在线观看| 国产精品在线看| 欧美性一二三区| 欧美日韩成人精品| 欧美激情黄色片| 欧美aⅴ99久久黑人专区| 久久久精品动漫| 欧美一级夜夜爽| 午夜亚洲福利| 午夜精品久久久久久99热软件| 99精品国产在热久久下载| 亚洲国产一区视频| 亚洲国产精品热久久| 欧美黑人在线观看| 亚洲第一精品在线| 欧美黄色影院| 亚洲人成久久| 亚洲精品字幕| 99一区二区| 亚洲视频导航| 亚洲欧美国产日韩天堂区| 亚洲一级二级| 亚洲一区免费在线观看| 亚洲免费婷婷| 欧美在线一二三| 久久九九热re6这里有精品 | aa级大片欧美三级| 一区二区三区毛片| 午夜精品福利视频| 欧美中日韩免费视频| 久久蜜桃资源一区二区老牛 | 性欧美办公室18xxxxhd| 久久精品一本久久99精品| 久久中文字幕一区| 欧美日韩成人| 国产情人节一区| 在线免费观看欧美| 一本一本久久| 欧美在线亚洲一区| 免费高清在线一区| 亚洲国产精品久久久久秋霞蜜臀| 亚洲精品久久嫩草网站秘色| 中文精品视频| 久久精品视频在线观看| 欧美成人在线网站| 国产精品久久久久久久久借妻| 国产毛片精品视频| 亚洲国产视频a| 亚洲在线一区| 欧美11—12娇小xxxx| 99re66热这里只有精品3直播| 性欧美1819性猛交| 欧美激情中文字幕一区二区| 国产精品亚洲综合一区在线观看| 精品动漫一区二区| 亚洲一区二区免费| 久久久久88色偷偷免费| 亚洲精品乱码久久久久久黑人| 亚洲综合99| 欧美国产一区二区在线观看| 国产精品一区视频| 亚洲精品久久久久中文字幕欢迎你| 亚洲欧美国产另类| 亚洲第一天堂无码专区| 亚洲欧美另类在线观看| 欧美大片网址| 激情国产一区| 香蕉久久夜色| 99国产精品| 欧美顶级少妇做爰|