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

            文章均收錄自他人博客,但不喜標題前加-[轉貼],因其丑陋,見諒!~
            隨筆 - 1469, 文章 - 0, 評論 - 661, 引用 - 0
            數據加載中……

            測試一下 Intel C++8.0 對模板的支持程度

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

            1.
            模板類靜態成員
            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.
            類成員函數模板
            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;
            }
            [
            ]:
            對于第二個成員函數模板,VC++6 運行異常

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

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

            7.
            空模板參數
            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]
            提供的一個事例
            struct Widget1 {
            template<typename T>
                T foo(){}
            };
            template<template<class T>class X>
                struct Widget2{
            };
            [
            ]:
            VC++6 編譯不通過

             

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

            99久久国产热无码精品免费久久久久| 久久www免费人成精品香蕉| 91久久香蕉国产熟女线看| 91精品观看91久久久久久| 婷婷综合久久狠狠色99h| 国产精品免费久久| 久久妇女高潮几次MBA| 国产精品国色综合久久| 99久久无码一区人妻| 国产偷久久久精品专区 | 亚洲一级Av无码毛片久久精品| 欧美亚洲国产精品久久| 久久精品九九亚洲精品| 人妻无码久久精品| 国内精品久久久久伊人av| 91精品国产91久久久久久青草| 久久国产亚洲精品无码| 精品无码人妻久久久久久| 久久不见久久见免费视频7| 久久精品亚洲精品国产欧美| 亚洲综合熟女久久久30p| 久久久WWW成人| 精品久久一区二区三区| 国产免费久久精品99re丫y| 嫩草影院久久99| 国产精品久久成人影院| 亚洲中文字幕无码久久2020| 99久久99久久精品国产片果冻| 国产成人综合久久精品尤物| 欧美午夜精品久久久久久浪潮| 久久久99精品成人片中文字幕| 精品无码久久久久久久动漫| 国产女人aaa级久久久级| 国产欧美一区二区久久| Xx性欧美肥妇精品久久久久久| 国产精品美女久久久久| 久久亚洲精品中文字幕三区| 国产麻豆精品久久一二三| 2021少妇久久久久久久久久| 久久中文娱乐网| 精品国产婷婷久久久|