• <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++ 模板

            久久精品国产99国产精偷| 一本综合久久国产二区| 国产精品99久久精品爆乳| 久久影院亚洲一区| 久久久久久人妻无码| 天天久久狠狠色综合| 精品国产乱码久久久久软件| 精品久久久久久久| 亚洲国产精品无码久久久蜜芽| 久久AAAA片一区二区| av无码久久久久不卡免费网站| 欧美日韩精品久久久久| 99久久精品免费看国产一区二区三区| 久久亚洲国产精品五月天婷| 国内精品久久久久影院免费| 久久久久亚洲AV无码专区首JN | 亚洲国产欧美国产综合久久| 国产AⅤ精品一区二区三区久久| 久久精品国产亚洲AV不卡| 久久精品国产亚洲5555| 国内精品久久久久影院免费| 久久久国产精品亚洲一区| 久久精品国产免费观看| 国产精品久久久久免费a∨| 久久久精品久久久久特色影视| 狠狠色噜噜狠狠狠狠狠色综合久久| 欧美日韩精品久久免费| 欧美亚洲国产精品久久| 欧美成人免费观看久久| 亚洲国产精品综合久久网络 | 狠狠色丁香婷婷久久综合不卡 | 波多野结衣AV无码久久一区| 99久久做夜夜爱天天做精品| 无码国内精品久久人妻麻豆按摩| 国产ww久久久久久久久久| 国产免费久久久久久无码| 青青草国产精品久久久久| 国产一区二区精品久久岳| 久久性精品| 成人综合久久精品色婷婷| 亚洲欧美成人综合久久久 |