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

            woaidongmao

            文章均收錄自他人博客,但不喜標(biāo)題前加-[轉(zhuǎn)貼],因其丑陋,見諒!~
            隨筆 - 1469, 文章 - 0, 評(píng)論 - 661, 引用 - 0
            數(shù)據(jù)加載中……

            測(cè)試一下 Intel C++8.0 對(duì)模板的支持程度

            有關(guān)模板的語法很多很雜,無法一一列舉,在此僅測(cè)試幾個(gè)簡(jiǎn)單常用的語法。
            以下有關(guān)模板的語法分別使用 Dev-CPP4991VC++6.0 Intel C++8.0 進(jìn)行測(cè)試,DEVCPPICC都能完全通過測(cè)試,VC++6有部分通不過測(cè)試。

            1.
            模板類靜態(tài)成員
            template <typename T> struct testClass {
                static int _data;
            };
            template<> int testClass<char>::_data = 1;
            template<> int testClass<long>::_data = 2;
            int main( void ) {
                cout << boolalpha << (1==testClass<char>::_data) << endl;
                cout << boolalpha << (2==testClass<long>::_data) << endl;
            }

            2.
            模板類偏特化
            template <class I, class O> struct testClass {
                testClass() { cout << "I, O" << endl; }
            };
            template <class T> struct testClass<T*, T*> {
                testClass() { cout << "T*, T*" << endl; }
            };
            template <class T> struct testClass<const T*, T*> {
                testClass() { cout << "const T*, T*" << endl; }
            };
            int main( void ) {
                testClass<int, char> obj1;
                testClass<int*, int*> obj2;
                testClass<const int*, int*> obj3;
            }
            [
            ]:
            VC++6 編譯不通過

            3. function template partial order
            template <class T> struct testClass {
                void swap( testClass<T>& ) { cout << "swap()" << endl; }
            };
            template <class T> inline void swap( testClass<T>& x, testClass<T>& y ) {
                x.swap( y );
            }
            int main( void ) {
                testClass<int> obj1;
                testClass<int> obj2;
                swap( obj1, obj2 );
            }
            [
            ]: VC++6 編譯不通過

            4.
            類成員函數(shù)模板
            struct testClass {
                template <class T> void mfun( const T& t ) {
                    cout << t << endl;
                }
                template <class T> operator T() {
                    return T();
                }
            };
            int main( void ) {
                testClass obj;
                obj.mfun( 1 );
                int i = obj;
                cout << i << endl;
            }
            [
            ]:
            對(duì)于第二個(gè)成員函數(shù)模板,VC++6 運(yùn)行異常

            5.
            缺省模板參數(shù)推導(dǎo)
            template <class T> struct test {
                T a;
            };
            template <class I, class O=test<I> > struct testClass {
                I b;
                O c;
            };

            6.
            非類型模板參數(shù)
            template <class T, int n> struct testClass {
                T _t;
                testClass() : _t(n) {
                }
            };
            int main( void ) {
                testClass<int,1> obj1;
                testClass<int,2> obj2;
            }

            7.
            空模板參數(shù)
            template <class T> struct testClass;
            template <class T> bool operator==( const testClass<T>&, const testClass<T>& ) {
                return false;
            };
            template <class T> struct testClass {
                friend bool operator== <>( const testClass&, const testClass& );
            };
            [
            ]:
            VC++6 編譯不通過

            8.
            模板特化
            template <class T> struct testClass {
            };
            template <> struct testClass<int> {
            };

            9.
            template <template <class T> class X>
                struct Widget{
            };
            [
            ]:
            VC++6 編譯不通過

            10. [hpho]
            提供的一個(gè)事例
            struct Widget1 {
            template<typename T>
                T foo(){}
            };
            template<template<class T>class X>
                struct Widget2{
            };
            [
            ]:
            VC++6 編譯不通過

             

            posted on 2008-09-15 13:07 肥仔 閱讀(328) 評(píng)論(0)  編輯 收藏 引用 所屬分類: C++ 模板

            丁香色欲久久久久久综合网| 久久久久久久久久久精品尤物| 99精品久久精品一区二区| 国产精品热久久无码av| 激情伊人五月天久久综合| 久久久久亚洲精品日久生情| 午夜精品久久久久9999高清| 超级碰久久免费公开视频| 97久久精品人人澡人人爽| 久久精品免费一区二区三区| 久久精品成人免费网站| 人人狠狠综合久久亚洲婷婷| 久久精品国产亚洲网站| 久久不射电影网| 国产高潮久久免费观看| 久久久久国产精品三级网| 久久久久久毛片免费看| 最新久久免费视频| 午夜精品久久久久久毛片| 久久婷婷五月综合97色| www.久久99| 久久久久噜噜噜亚洲熟女综合 | 色婷婷综合久久久中文字幕| 精产国品久久一二三产区区别| 2020国产成人久久精品| 国产亚洲精品久久久久秋霞 | 久久亚洲私人国产精品vA| 国产精品久久久亚洲| 岛国搬运www久久| 热RE99久久精品国产66热| 亚洲精品无码久久久久去q| 精品国际久久久久999波多野| 91精品日韩人妻无码久久不卡| 久久99精品久久久久久不卡| 久久久久国产精品人妻| 99久久99这里只有免费的精品| 99精品伊人久久久大香线蕉| 97精品伊人久久大香线蕉| 国产成人精品久久一区二区三区| 久久精品免费大片国产大片| 97精品伊人久久久大香线蕉|