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

            評論

            # re: VC編譯器對FunctionTemplate實例化的優化 2005-12-17 15:12 清風雨

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

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

            一樓說得對  回復  更多評論   

            亚洲成人精品久久| 亚洲国产精品综合久久网络| 麻豆AV一区二区三区久久| 久久人人爽人人爽人人片AV不 | 久久99中文字幕久久| 国产精品午夜久久| 久久精品国产2020| 久久久久国产精品三级网| 久久偷看各类wc女厕嘘嘘| 久久人人爽人爽人人爽av| 777米奇久久最新地址| 一级a性色生活片久久无| 热久久这里只有精品| 久久亚洲中文字幕精品有坂深雪| 国产精品免费久久久久电影网| 久久国语露脸国产精品电影| 久久久久97国产精华液好用吗| 久久ZYZ资源站无码中文动漫| 久久人人爽人人爽人人片av麻烦| 久久99国产一区二区三区| 免费观看成人久久网免费观看| 色狠狠久久AV五月综合| 午夜精品久久久久久| 国产成人99久久亚洲综合精品| 久久国产亚洲高清观看| 亚洲中文字幕无码久久2020| 久久久久亚洲AV无码观看| 精品人妻伦九区久久AAA片69| 7国产欧美日韩综合天堂中文久久久久| 久久综合给合久久狠狠狠97色69| 久久久久久精品久久久久| 免费无码国产欧美久久18| 亚洲婷婷国产精品电影人久久| 女同久久| 久久精品国产色蜜蜜麻豆| 97精品伊人久久久大香线蕉| 亚洲va中文字幕无码久久| 亚洲va久久久噜噜噜久久狠狠 | 久久强奷乱码老熟女网站| 久久精品视频91| 中文字幕无码精品亚洲资源网久久|