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

            評(píng)論

            # 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ù)  更多評(píng)論   

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

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


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


            国产巨作麻豆欧美亚洲综合久久| 久久天天躁狠狠躁夜夜avapp| 91精品国产综合久久香蕉| 青青国产成人久久91网| 久久一本综合| 精品久久久久久无码专区| 久久亚洲AV无码西西人体| 国产产无码乱码精品久久鸭| 香蕉久久一区二区不卡无毒影院 | 欧美亚洲另类久久综合| 99久久精品免费看国产免费| 久久综合鬼色88久久精品综合自在自线噜噜 | 无码精品久久久久久人妻中字| 日韩AV无码久久一区二区 | 人妻系列无码专区久久五月天| 色婷婷综合久久久中文字幕| 久久精品无码一区二区app| 国产情侣久久久久aⅴ免费| 三级三级久久三级久久| 精品一久久香蕉国产线看播放| 成人妇女免费播放久久久| 久久亚洲日韩看片无码| 亚洲一区精品伊人久久伊人| 办公室久久精品| 国产99久久九九精品无码| 久久99精品国产一区二区三区| 久久久一本精品99久久精品66| 欧美激情精品久久久久久| 久久久久97国产精华液好用吗| 亚洲午夜精品久久久久久人妖| 99久久er这里只有精品18| 国产精品免费看久久久| 97超级碰碰碰久久久久| 久久精品国产亚洲av高清漫画| 久久精品国产亚洲AV无码娇色| 性色欲网站人妻丰满中文久久不卡| 国产69精品久久久久久人妻精品| 久久久久久久91精品免费观看| 久久乐国产综合亚洲精品| 久久久久久久女国产乱让韩| 久久人人爽人人爽人人片AV高清 |