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

            評論

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

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

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

            一樓說得對  回復  更多評論   

            国产91色综合久久免费| 青春久久| 九九久久精品无码专区| 久久久噜噜噜久久| 精品蜜臀久久久久99网站| 久久成人18免费网站| 亚洲国产成人久久综合一区77| 国色天香久久久久久久小说 | 青青青青久久精品国产h| 久久久久久A亚洲欧洲AV冫| 亚洲AV日韩精品久久久久| 久久久亚洲精品蜜桃臀| 久久99国产综合精品| 久久人妻少妇嫩草AV蜜桃| 青青草国产成人久久91网| 亚洲va国产va天堂va久久| 欧美精品丝袜久久久中文字幕 | 99久久精品国产毛片| 久久99久国产麻精品66| 免费一级做a爰片久久毛片潮| 精品蜜臀久久久久99网站| 久久久一本精品99久久精品88| 久久线看观看精品香蕉国产| 久久精品国产AV一区二区三区| 国内精品久久久久久久久电影网 | 日韩电影久久久被窝网| 久久国产精品无码网站| 久久中文字幕一区二区| 国产精品久久免费| 国产精品久久99| www.久久热.com| 亚洲国产成人久久综合碰碰动漫3d | AV无码久久久久不卡网站下载| 国产精品久久新婚兰兰| 欧美亚洲国产精品久久| 老男人久久青草av高清| 亚洲精品国产美女久久久| 色诱久久久久综合网ywww| 久久久久国产精品熟女影院| 国产高潮国产高潮久久久| 久久亚洲精品视频|