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

            一樓說得對  回復  更多評論   

            久久人人爽人人爽人人片AV不| 久久精品国产亚洲AV不卡| 久久精品国产亚洲AV高清热| 91精品国产色综合久久| 国产精品久久国产精麻豆99网站| 久久99热只有频精品8| 久久精品国产亚洲沈樵| 国内精品伊人久久久久网站| 2021国内久久精品| 久久香蕉一级毛片| 亚洲午夜无码久久久久小说| 人妻丰满AV无码久久不卡| 中文字幕亚洲综合久久| 亚洲欧美久久久久9999| 精品久久久久久中文字幕| 一97日本道伊人久久综合影院| 国内精品久久久久久99蜜桃| 伊人久久大香线蕉综合网站| 国产精品免费看久久久| 久久久亚洲精品蜜桃臀| 91久久精品91久久性色| 狠狠色狠狠色综合久久| 久久最新免费视频| 国产日韩欧美久久| 国产精品99久久精品| 18禁黄久久久AAA片| 青青草原综合久久大伊人导航| 99久久无色码中文字幕| 久久精品蜜芽亚洲国产AV| 97香蕉久久夜色精品国产| 久久激情五月丁香伊人| 久久亚洲欧美日本精品| 成人资源影音先锋久久资源网| 亚洲va中文字幕无码久久不卡| 久久亚洲精品成人无码网站| 久久久无码精品亚洲日韩软件| 国产精品成人久久久久三级午夜电影 | 久久久久久综合网天天| 丰满少妇人妻久久久久久4| 久久超碰97人人做人人爱| 97久久香蕉国产线看观看|