• <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)貼],因其丑陋,見(jiàn)諒!~
            隨筆 - 1469, 文章 - 0, 評(píng)論 - 661, 引用 - 0
            數(shù)據(jù)加載中……

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

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

            1.
            模板類(lèi)靜態(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.
            模板類(lèi)偏特化
            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 編譯不通過(guò)

            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 編譯不通過(guò)

            4.
            類(lèi)成員函數(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.
            非類(lèi)型模板參數(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 編譯不通過(guò)

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

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

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

             

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

            亚洲成色www久久网站夜月| 人妻无码αv中文字幕久久琪琪布 人妻无码精品久久亚瑟影视 | 麻豆成人久久精品二区三区免费| 亚洲精品tv久久久久久久久久| 久久久久国产亚洲AV麻豆| 奇米综合四色77777久久| 日韩精品久久久久久久电影蜜臀| 2021精品国产综合久久| 91久久九九无码成人网站| 亚洲中文字幕伊人久久无码| 国产亚洲精品久久久久秋霞| 久久综合丝袜日本网| 亚洲欧美日韩久久精品| 久久99国产精品一区二区| 色婷婷综合久久久久中文字幕| 少妇久久久久久久久久| 精品久久久久一区二区三区| 成人久久免费网站| 精品国产一区二区三区久久蜜臀| 午夜精品久久久久久99热| 国产精品久久久久久久午夜片 | 日韩欧美亚洲综合久久| 国产亚洲精午夜久久久久久| 欧美熟妇另类久久久久久不卡| 久久艹国产| 中文精品久久久久国产网址| 国产亚洲欧美精品久久久| 亚洲精品97久久中文字幕无码| 精品水蜜桃久久久久久久| 国产国产成人精品久久| 色诱久久久久综合网ywww| 亚洲欧美久久久久9999| 青青热久久国产久精品| 久久精品无码一区二区日韩AV| 69SEX久久精品国产麻豆| 久久ZYZ资源站无码中文动漫| 久久久久久久免费视频| 亚洲精品国产综合久久一线| 久久有码中文字幕| 欧美久久一区二区三区| 亚洲午夜久久久|