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

            評論

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

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

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

            一樓說得對  回復  更多評論   

            久久综合九色综合欧美狠狠| 99久久精品无码一区二区毛片| 欧美精品一区二区久久| 青青草原综合久久大伊人精品| 久久AⅤ人妻少妇嫩草影院| 久久人人爽人人人人片av| 久久久一本精品99久久精品88| 亚洲国产精品久久久久网站| 久久夜色精品国产噜噜亚洲a | 久久精品亚洲欧美日韩久久| 久久精品国产亚洲AV香蕉| 亚洲国产精品一区二区久久| 国产一区二区精品久久凹凸 | 99久久这里只有精品| 久久精品国产99久久久古代| 久久91亚洲人成电影网站| 久久人妻少妇嫩草AV无码蜜桃| 久久精品国产亚洲77777| 久久天天躁狠狠躁夜夜躁2014| 精品一区二区久久久久久久网站| 久久精品国产亚洲av高清漫画| 99久久国产免费福利| 久久发布国产伦子伦精品| 久久精品成人| 久久精品国产亚洲麻豆| 国产99久久久久久免费看 | 亚洲精品无码专区久久久| 久久久久久亚洲精品不卡| 精品国产乱码久久久久软件| Xx性欧美肥妇精品久久久久久| 性欧美丰满熟妇XXXX性久久久| 狠狠人妻久久久久久综合| 青青草原综合久久大伊人精品| 99久久精品免费看国产一区二区三区 | 久久久综合香蕉尹人综合网| 久久国产精品无码网站| 久久亚洲高清综合| 久久免费视频6| 2019久久久高清456| 久久午夜无码鲁丝片午夜精品| 94久久国产乱子伦精品免费|