• <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 閱讀(551) 評(píng)論(2)  編輯 收藏 引用

            評(píng)論

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

            這個(gè)不是優(yōu)化,是語(yǔ)言本身對(duì)模板的要求。也就是說C++語(yǔ)言本身就決定了這個(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   管理


            国产精品久久网| 久久精品蜜芽亚洲国产AV| 伊人久久免费视频| 久久99热这里只有精品国产| 久久精品视频一| 欧美精品一本久久男人的天堂| 激情五月综合综合久久69| 久久亚洲国产成人影院| 欧美一区二区三区久久综合| 青青青青久久精品国产h| 久久综合九色综合久99| 久久久久久久97| 亚洲乱码日产精品a级毛片久久 | 国产精品无码久久综合| 99久久精品国产毛片| 亚洲精品无码久久毛片| 国产福利电影一区二区三区久久久久成人精品综合 | 国产午夜精品久久久久九九电影| 亚洲欧洲久久av| 亚洲成色999久久网站| 亚洲国产精品无码久久久秋霞2 | 亚洲愉拍99热成人精品热久久| AA级片免费看视频久久| 久久精品人成免费| 久久久老熟女一区二区三区| 理论片午午伦夜理片久久| 久久综合狠狠色综合伊人| 久久久久久久女国产乱让韩| 国产精品热久久无码av| 丰满少妇人妻久久久久久4| 亚洲精品乱码久久久久久蜜桃图片| 久久se精品一区精品二区国产| 久久免费精品一区二区| 99久久久精品免费观看国产| 日韩精品久久久久久久电影蜜臀| 色天使久久综合网天天| 热久久国产欧美一区二区精品| 久久91这里精品国产2020| 久久av免费天堂小草播放| 久久人搡人人玩人妻精品首页| 久久天天日天天操综合伊人av|