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

            評(píng)論

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

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

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


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


            久久e热在这里只有国产中文精品99 | 久久综合给合综合久久| 一本伊大人香蕉久久网手机| 一本久久久久久久| 久久人与动人物a级毛片| 久久久久亚洲av无码专区导航| 精品久久久久中文字幕日本| 国产69精品久久久久99| 亚洲欧美日韩中文久久| 亚洲狠狠久久综合一区77777| 亚洲国产成人乱码精品女人久久久不卡| 午夜精品久久久久久影视riav| 久久久久亚洲av无码专区导航 | 99久久国产宗和精品1上映| 久久精品天天中文字幕人妻| 99久久综合狠狠综合久久| 久久久国产精华液| 久久影院久久香蕉国产线看观看| 色欲av伊人久久大香线蕉影院| 青青草原1769久久免费播放| 亚洲成色WWW久久网站| 久久综合给合综合久久| 91精品婷婷国产综合久久| 日韩精品无码久久久久久| 亚洲精品tv久久久久| 久久国产影院| 国产精品VIDEOSSEX久久发布| 波多野结衣中文字幕久久| 亚洲中文精品久久久久久不卡| 国产午夜福利精品久久| 日本精品久久久久中文字幕8| 久久亚洲精品国产精品婷婷| 久久高清一级毛片| 999久久久国产精品| 99久久精品免费看国产| 久久777国产线看观看精品| 欧美丰满熟妇BBB久久久| 精品国产乱码久久久久久1区2区 | 中文字幕日本人妻久久久免费 | 久久精品极品盛宴观看| 欧美久久久久久午夜精品|