• <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>
            Windreamer Is Not a DREAMER
            main(){main(puts("Hello,stranger!"));}

            終于無(wú)聊到來(lái)寫書評(píng),最近的項(xiàng)目一直都沒(méi)和C++有什么關(guān)系,不過(guò)看的書卻都是C++方面的,而最近看到的幾本書中感覺(jué)最好的莫過(guò)于這本《C++ Templates》

            Nicolai M. Josuttis的書我很喜歡,從他的那本《The C++ Standard Template Library》就看出了他很多獨(dú)特的風(fēng)格,令我愛(ài)不釋手,所以這本《C++ Template》   也進(jìn)入了我的必看書單。粗讀之后,感覺(jué)整本書絕對(duì)將成為C++泛型領(lǐng)域的圣經(jīng)級(jí)著作

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

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

            下面是我看書時(shí)畫下來(lái)的一些覺(jué)得自己平時(shí)應(yīng)該注意的地方,放在這里做備忘好了

            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] 太長(zhǎng)了,略過(guò)
            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技術(shù)(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};
              }
              ;

            總而言之,此書帶給了我前所未有的閱讀享受......我今年震撼大獎(jiǎng)一定會(huì)投它一票
            posted on 2005-12-10 12:36 Windreamer Is Not DREAMER 閱讀(623) 評(píng)論(3)  編輯 收藏 引用 所屬分類: Generic
            Comments

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


             
            www.久久热| 91精品国产色综合久久| 国产精品久久久久久搜索| 久久久久久久99精品免费观看| 久久夜色精品国产亚洲| 亚洲国产成人久久综合碰碰动漫3d| 久久午夜福利电影| 伊人情人综合成人久久网小说| 久久婷婷激情综合色综合俺也去 | 麻豆精品久久精品色综合| 情人伊人久久综合亚洲| 久久亚洲AV成人无码软件| 热久久国产精品| 久久久噜噜噜久久中文字幕色伊伊 | 久久天天躁狠狠躁夜夜不卡| 久久久久久久波多野结衣高潮| 成人久久久观看免费毛片| 亚洲午夜精品久久久久久浪潮| 伊人久久大香线焦综合四虎| 伊人久久大香线蕉无码麻豆| 婷婷久久综合九色综合98| 久久受www免费人成_看片中文| 久久精品草草草| 国产精品99久久不卡| 久久丫精品国产亚洲av不卡| 国产精品VIDEOSSEX久久发布| 久久久久久亚洲Av无码精品专口| 伊人久久大香线蕉精品不卡| 青青草国产精品久久久久| 亚洲午夜久久久久久久久久| 伊人久久大香线焦AV综合影院 | 欧美精品丝袜久久久中文字幕 | 91精品国产91热久久久久福利 | 久久AV高潮AV无码AV| 午夜精品久久久久9999高清| 久久精品国产99久久丝袜 | 久久久久久久免费视频| 久久免费视频一区| 无码人妻少妇久久中文字幕 | 久久久久亚洲AV片无码下载蜜桃| 性欧美大战久久久久久久|