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

            一樓說得對  回復  更多評論   

            国产激情久久久久影院老熟女免费 | 久久久久久青草大香综合精品| 久久精品国产只有精品2020 | 激情综合色综合久久综合| 99久久免费国产精品| 97精品国产97久久久久久免费| 久久久av波多野一区二区| 久久国产免费观看精品| 欧美久久亚洲精品| 久久精品国产亚洲AV麻豆网站 | 国产香蕉久久精品综合网| 久久亚洲中文字幕精品有坂深雪| 久久最近最新中文字幕大全| 伊人色综合久久天天人守人婷| 久久精品国产亚洲AV嫖农村妇女| 亚洲&#228;v永久无码精品天堂久久| 777午夜精品久久av蜜臀 | 国产成人精品免费久久久久| 久久只有这里有精品4| 国产成人精品综合久久久| 精品综合久久久久久888蜜芽| 2021国内久久精品| 麻豆国内精品久久久久久| 色综合久久综精品| 久久精品国产一区| 99久久精品毛片免费播放| 久久精品国产亚洲av日韩| 亚洲中文久久精品无码ww16 | av午夜福利一片免费看久久| 综合久久给合久久狠狠狠97色| 久久精品成人一区二区三区| 久久精品国产91久久综合麻豆自制 | 伊人久久一区二区三区无码| 久久99久久无码毛片一区二区| 91超碰碰碰碰久久久久久综合| 久久99中文字幕久久| 久久国产精品久久| 国产三级观看久久| 久久精品国产福利国产琪琪| 久久综合久久鬼色| 久久免费看黄a级毛片|