• <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>

            Edgard

            VC編譯器對(duì)FunctionTemplate實(shí)例化的優(yōu)化

            VC編譯器對(duì)FunctionTemplate實(shí)例化的優(yōu)化:
            看下面Template代碼:

            inline int const& max (int const& a, int const& b)
            {
                return a<b?b:a;
            }

            // maximum of two values of any type
            template <typename T>
            inline T const& max (T const& a, T const& b)
            {
                return a<b?b:a;
            }

            // maximum of three values of any type
            template <typename T>
            inline T const& max (T const& a, T const& b, T const& c)
            {
                return max (max(a,b), c);
            }

            inline int const& max (int const& a, int const& b) 已經(jīng)是template <typename T>
            inline T const& max (T const& a, T const& b) 對(duì)類型int的實(shí)例化,所以,凡是需要調(diào)用max<int>時(shí),VC 編譯器都不在再用max<int>來Instantiate max Function Template.


            int main ()

                ::max(7, 42, 68); // calls the template for three arguments first, then call inline int const& max   
                   

                ::max(7.0, 42.0); // calls max<double> (by argument deduction)
                ::max('a', 'b'); // calls max<char> (by argument deduction)
                ::max(7, 42);  // calls the nontemplate for two ints 
             
                ::max<>(7, 42);  // call inline int const& max
                ::max<int>(7, 42); // call inline int const& max
                ::max<int>(7.0, 42.0); // call inline int const& max
                ::max<double>(7, 42); // calls max<double> (no argument deduction)

               return 0;
            }

            posted on 2005-12-15 20:43 Edgard 閱讀(562) 評(píng)論(2)  編輯 收藏 引用

            評(píng)論

            # re: VC編譯器對(duì)FunctionTemplate實(shí)例化的優(yōu)化 2005-12-17 15:12 清風(fēng)雨

            這個(gè)不是優(yōu)化,是語言本身對(duì)模板的要求。也就是說C++語言本身就決定了這個(gè)結(jié)果是必然結(jié)果。不管那個(gè)編譯器正確的行為都是這個(gè)結(jié)果。而不是編譯器的代碼優(yōu)化。  回復(fù)  更多評(píng)論   

            # re: VC編譯器對(duì)FunctionTemplate實(shí)例化的優(yōu)化 2006-03-05 21:02 filcon

            一樓說得對(duì)  回復(fù)  更多評(píng)論   


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


            久久精品夜色噜噜亚洲A∨| 久久精品国产99久久久古代| 国产精品99久久久久久猫咪| 少妇被又大又粗又爽毛片久久黑人| 国内精品伊人久久久久妇| 国产精品久久久久久久| 久久久久香蕉视频| 久久无码人妻一区二区三区| 久久伊人亚洲AV无码网站| 久久久久亚洲AV无码麻豆| 久久久久久极精品久久久| 久久精品中文字幕无码绿巨人| 久久久久国色AV免费看图片 | 国产高清国内精品福利99久久| 久久精品免费大片国产大片 | 免费观看成人久久网免费观看| 亚洲日本久久久午夜精品| 久久久久免费精品国产| 久久婷婷五月综合国产尤物app| 久久成人国产精品一区二区| 久久久免费精品re6| 久久精品国产亚洲AV影院| 久久伊人亚洲AV无码网站| 99久久精品久久久久久清纯| 99精品国产在热久久无毒不卡| 亚洲αv久久久噜噜噜噜噜| 精品久久久久久久国产潘金莲| 久久久精品久久久久特色影视| 亚洲国产精品久久66| 亚洲嫩草影院久久精品| 久久青草国产手机看片福利盒子| 日产精品久久久一区二区| 欧美精品久久久久久久自慰| 色偷偷88888欧美精品久久久| 久久久www免费人成精品| 精品国产乱码久久久久软件| 久久久精品国产免大香伊| 久久人人爽人人爽人人AV东京热 | 久久最新免费视频| 噜噜噜色噜噜噜久久| 日韩乱码人妻无码中文字幕久久 |