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

            一樓說得對  回復  更多評論   

            久久精品国产AV一区二区三区 | 伊人久久大香线蕉av不变影院| yy6080久久| 久久久久人妻精品一区三寸蜜桃| 久久91亚洲人成电影网站| 精品久久久久久国产牛牛app| 热RE99久久精品国产66热| 久久人妻AV中文字幕| 久久久久久久99精品免费观看| 青草久久久国产线免观| 99久久精品免费看国产一区二区三区| 久久精品午夜一区二区福利| 久久99国产精品成人欧美| 久久无码人妻一区二区三区| 久久亚洲国产精品五月天婷| 国产成人精品白浆久久69| 污污内射久久一区二区欧美日韩 | 大蕉久久伊人中文字幕| 久久久噜噜噜久久中文字幕色伊伊 | 99国产欧美久久久精品蜜芽| 国产成人久久精品二区三区| 欧美午夜精品久久久久免费视| 亚洲国产高清精品线久久| 91精品久久久久久无码| 久久A级毛片免费观看| 亚洲精品美女久久777777| 亚洲国产小视频精品久久久三级| 久久se精品一区二区| avtt天堂网久久精品| 久久亚洲中文字幕精品有坂深雪 | 99re这里只有精品热久久 | 久久99国产精品久久99果冻传媒| 青青草原精品99久久精品66| 伊人久久精品无码二区麻豆| 一本久久综合亚洲鲁鲁五月天| 亚洲伊人久久综合中文成人网| 无码乱码观看精品久久| 久久婷婷午色综合夜啪| 伊人久久综合无码成人网| 婷婷综合久久中文字幕蜜桃三电影| 亚洲精品无码久久一线|