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


            久久99精品久久久久久久不卡| 国内精品久久久久影院一蜜桃 | 久久人人爽人人爽人人片AV高清 | 国产99久久精品一区二区| 日韩欧美亚洲综合久久 | 99热都是精品久久久久久| 72种姿势欧美久久久久大黄蕉| 77777亚洲午夜久久多喷| 亚洲国产精品久久久久婷婷软件 | 精品久久久久久久久久中文字幕 | 国内精品九九久久精品| 99久久久国产精品免费无卡顿| 久久99热狠狠色精品一区| 久久久久久亚洲精品不卡| 亚洲精品高清国产一线久久| 欧美亚洲另类久久综合| 伊人色综合久久天天人守人婷 | 色综合久久中文字幕无码| 91精品国产高清久久久久久国产嫩草| 久久久精品视频免费观看| 久久综合给久久狠狠97色| 久久精品中文字幕一区| 国产精品视频久久| 日韩影院久久| 日本久久久精品中文字幕| 日韩精品久久无码人妻中文字幕 | 国产高潮久久免费观看| 久久久国产精品亚洲一区| 狠狠精品久久久无码中文字幕 | 久久婷婷国产剧情内射白浆| 一本大道久久a久久精品综合| 日韩人妻无码精品久久久不卡| 日本精品一区二区久久久| 欧美亚洲另类久久综合| 国产精品欧美久久久天天影视| 国内精品伊人久久久久妇| 久久久久国产| 女同久久| 久久久精品视频免费观看| 日韩精品无码久久一区二区三| 青春久久|