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

            VC編譯器對FunctionTemplate實(shí)例化的優(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的實(shí)例化,所以,凡是需要調(diào)用max<int>時(shí),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 閱讀(552) 評論(2)  編輯 收藏 引用

            評論

            # re: VC編譯器對FunctionTemplate實(shí)例化的優(yōu)化 2005-12-17 15:12 清風(fēng)雨

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

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

            一樓說得對  回復(fù)  更多評論   


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            亚洲国产日韩欧美久久| 精品久久久无码人妻中文字幕 | 一本大道加勒比久久综合| 国产一久久香蕉国产线看观看| 国产成人久久久精品二区三区| 日本亚洲色大成网站WWW久久| 久久精品无码一区二区WWW| 97久久久精品综合88久久| 久久久精品久久久久久| 亚洲va中文字幕无码久久| 国产L精品国产亚洲区久久 | 狠狠精品久久久无码中文字幕| 久久无码AV中文出轨人妻| 国产亚洲欧美精品久久久| 久久久久这里只有精品| 久久精品成人免费看| 亚洲AV无一区二区三区久久 | 国产成人精品久久亚洲| 伊人久久大香线蕉综合影院首页| 久久er国产精品免费观看2| 亚洲欧洲日产国码无码久久99| 狠狠精品久久久无码中文字幕| 久久99亚洲网美利坚合众国| 伊人久久大香线蕉精品不卡| 精品久久久久久国产三级| 久久九九亚洲精品| 无码人妻久久久一区二区三区| 欧美成人免费观看久久| 久久久久久噜噜精品免费直播| 久久99国产精品久久| 国产V综合V亚洲欧美久久| 成人综合伊人五月婷久久| 久久综合给合久久狠狠狠97色 | 欧美国产精品久久高清| 国产精品青草久久久久福利99| 国产亚洲精品自在久久| 久久久久久免费一区二区三区| 久久精品中文字幕无码绿巨人| 国内精品人妻无码久久久影院导航| 久久久久久久久66精品片| 久久乐国产综合亚洲精品|