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

            評論

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

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

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

            一樓說得對  回復  更多評論   

            亚洲精品久久久www| 亚洲国产天堂久久综合| 久久久综合九色合综国产| 精品久久久久久久久中文字幕| 国产精品久久精品| 伊色综合久久之综合久久| 一本色道久久综合亚洲精品| 99久久婷婷免费国产综合精品| 国产农村妇女毛片精品久久| 人妻精品久久无码专区精东影业| 久久久精品午夜免费不卡| 亚洲精品乱码久久久久久蜜桃不卡| 99久久精品费精品国产| 亚洲AV日韩精品久久久久久| 久久伊人五月天论坛| 国产91久久综合| 久久激情五月丁香伊人| 91精品久久久久久无码| 国产成人久久精品二区三区| 久久丫精品国产亚洲av| 久久人人爽人人爽人人片AV不| 精品久久久中文字幕人妻| 久久亚洲AV成人无码| 久久综合狠狠综合久久综合88 | A级毛片无码久久精品免费| 久久天天躁狠狠躁夜夜2020老熟妇| 色综合久久久久无码专区| 精品免费久久久久国产一区 | 午夜天堂精品久久久久| 青青国产成人久久91网| 久久精品无码一区二区三区| 久久久国产精品亚洲一区| 一本色综合网久久| 欧美日韩中文字幕久久伊人| 久久久无码精品午夜| 亚洲国产美女精品久久久久∴| 久久综合中文字幕| 国产巨作麻豆欧美亚洲综合久久| 亚洲成色999久久网站| 丁香狠狠色婷婷久久综合| 精品国产乱码久久久久久郑州公司 |