• <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!"));}

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

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

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

            同類書籍據(jù)我所知沒有可以達到這個高度的,大部分C++泛型方面的專著只局限于怎么用STL,將模板基礎的書,也僅限于最表面的語法,像模版參數(shù)推導這種問題鮮有涉及,更不用提關于Metaprogramming,這本書圣經(jī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] 太長了,略過
            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 on 2005-12-10 12:36 Windreamer Is Not DREAMER 閱讀(611) 評論(3)  編輯 收藏 引用 所屬分類: Generic
            Comments
             
            精品水蜜桃久久久久久久| 亚洲中文字幕无码久久综合网| 狠狠久久综合伊人不卡| 亚洲狠狠久久综合一区77777| 99国产精品久久| 午夜精品久久久久成人| 香蕉久久夜色精品国产小说| 久久人搡人人玩人妻精品首页 | 久久国产高清一区二区三区| 成人妇女免费播放久久久| 国产日韩欧美久久| 亚洲精品高清国产一线久久| 久久久久久久精品妇女99| 欧美日韩精品久久久免费观看| 武侠古典久久婷婷狼人伊人| 亚洲va久久久噜噜噜久久男同| 国内精品久久久久影院日本| 91久久精品国产成人久久| 亚洲欧美国产精品专区久久 | 婷婷久久综合九色综合绿巨人| 99久久久久| 久久亚洲美女精品国产精品| 91精品国产综合久久精品| 青青草原综合久久大伊人| 国产精品久久久久AV福利动漫| 免费观看久久精彩视频| 国内精品久久国产大陆| 亚洲人成网亚洲欧洲无码久久 | 久久久久国产一区二区| 亚洲国产精品久久久久婷婷软件| 国产偷久久久精品专区| 久久久久久久尹人综合网亚洲| 久久99精品久久只有精品 | 狠狠色丁香久久婷婷综| 久久久久久亚洲精品成人| 欧美久久久久久| 色综合久久88色综合天天 | 精品久久久久久久| 青青草国产成人久久91网| 久久这里只有精品首页| 久久99精品国产|