• <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實例化的優(yōu)化

            VC編譯器對FunctionTemplate實例化的優(yōu)化:
            看下面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) 已經(jīng)是template <typename T>
            inline T const& max (T const& a, T const& b) 對類型int的實例化,所以,凡是需要調(diào)用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實例化的優(yōu)化 2005-12-17 15:12 清風雨

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

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

            一樓說得對  回復  更多評論   

            国产精品gz久久久| 久久亚洲日韩精品一区二区三区 | 久久99精品久久久久久野外| 久久久久亚洲AV成人网人人网站| 久久久久人妻一区二区三区| 1000部精品久久久久久久久| 97视频久久久| 国产精品美女久久久久av爽| 久久精品水蜜桃av综合天堂| 久久精品亚洲男人的天堂| 久久精品国产久精国产思思| 人妻丰满?V无码久久不卡| 国产精品久久久久9999| 亚洲AV无码久久精品狠狠爱浪潮| 久久精品成人| 国产精品成人99久久久久| 久久99精品久久久久久动态图| 一本色综合久久| 久久久久久久久久久免费精品| 久久99热国产这有精品| 久久久久亚洲av无码专区导航 | 久久精品国产亚洲AV无码麻豆| 久久夜色精品国产亚洲av| 国产成人AV综合久久| 国产精品一区二区久久国产| 99蜜桃臀久久久欧美精品网站 | 久久中文字幕人妻丝袜| 久久一区二区免费播放| 日韩精品无码久久一区二区三| 91精品观看91久久久久久| 久久综合久久综合久久综合| 久久99国产精品99久久| 久久婷婷国产麻豆91天堂| 日本久久久久久中文字幕| 99热精品久久只有精品| 国产精品伊人久久伊人电影| 精品视频久久久久| 欧美成人免费观看久久| 久久影院综合精品| 国产精品久久久久久影院| 99久久综合国产精品二区|