• <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編譯器對FunctionTemplate實例化的優化

            VC編譯器對FunctionTemplate實例化的優化:
            看下面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) 已經是template <typename T>
            inline T const& max (T const& a, T const& b) 對類型int的實例化,所以,凡是需要調用max<int>時,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 閱讀(550) 評論(2)  編輯 收藏 引用

            評論

            # re: VC編譯器對FunctionTemplate實例化的優化 2005-12-17 15:12 清風雨

            這個不是優化,是語言本身對模板的要求。也就是說C++語言本身就決定了這個結果是必然結果。不管那個編譯器正確的行為都是這個結果。而不是編譯器的代碼優化。  回復  更多評論   

            # re: VC編譯器對FunctionTemplate實例化的優化 2006-03-05 21:02 filcon

            一樓說得對  回復  更多評論   

            九九久久精品国产| 久久久久久人妻无码| 久久中文字幕无码专区| 久久精品中文无码资源站| 69国产成人综合久久精品| 亚洲国产精品久久66| 久久久久久久波多野结衣高潮| 久久AV高清无码| 久久精品亚洲欧美日韩久久| 久久99精品久久久久久动态图| 18禁黄久久久AAA片| 色婷婷综合久久久久中文字幕| 免费精品99久久国产综合精品| 国产激情久久久久久熟女老人| 国产精品熟女福利久久AV| 狠狠色丁香婷婷久久综合不卡| 人妻精品久久无码专区精东影业| 久久婷婷国产剧情内射白浆| 国产一区二区精品久久凹凸| 夜夜亚洲天天久久| 99热成人精品免费久久| 久久一区二区三区99| 香蕉久久永久视频| 久久久久亚洲AV无码专区体验| 亚洲午夜久久久久久久久久| 乱亲女H秽乱长久久久| 精品久久久久久成人AV| 久久国产一区二区| 久久亚洲电影| 2021国产成人精品久久| 久久精品青青草原伊人| 青青热久久综合网伊人| 国色天香久久久久久久小说| 99国内精品久久久久久久| 国产Av激情久久无码天堂| 午夜精品久久久久久影视777| 国产精品99精品久久免费| 久久精品卫校国产小美女| 99久久精品国产毛片| 精品久久久久香蕉网| 狠狠88综合久久久久综合网 |