日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

STL源代码分析(ch 1)组态2

發布時間:2025/3/21 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 STL源代码分析(ch 1)组态2 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

4. __STL_MEMBER_TEMPLATES

模板類中包含模板成員,是否支持template members of classes

class vec { public:typedef T value_type;typedef value_type* iterator;template<class I>void insert(iterator position, I first, I last) {cout << "insert()" << endl;} };int main() {int ia[5] = { 0,1,2,3,4 };vec<int> a;vec<int>::iterator ite;a.insert(ite, ia, ia + 5); }

5. __STL_LIMITED_DEFAULT_TEMPLAES

用到前一個模板的模板形參的某一個具現體作為當前模板的模板形參的默認值

template <class T,class Alloc=alloc,size_t BufSiz=0> class deque { public:deque() { cout << deque() << endl; } };template <class T,class Sequence=deque<T>> class stack { public:stack() { cout << "Stack" << endl; } private:Sequence c; };int main() {stack<int> x; }

6. __STL_NON_TYPE_TMPL_PARAM_BUG

類模板是否使用非類型模板參數(non-type template parameters)

通常它們只能是常數整數(constant integral values )包括枚舉,或者是指向外部鏈接的指針。
不能把float,class-type類型的對象,內部鏈接(internal linkage )對象,作為非類型模板參數。

template <class T,class Alloc=alloc,size_t BufSiz=0> //BufSiz即為非類型模板。 class deque { public:deque() { cout << deque() << endl; } };

7.__STL_TEMPLATE_NULL

指定一種或多種模板形參的實際值或實際類型,作為特殊情況

#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION # define __STL_TEMPLATE_NULL template<> #else # define __STL_TEMPLATE_NULL #endif template<class type> struct __type_traits{ ...};//非特化情況均使用這個 __STL_TEMPLATE_NULL struct __type_traits<char> { ... };//特化char情況template<class Key> struct hash { };//非特化情況均使用這個 __STL_TEMPLATE_NULL struct hash<char> { ... };//特化char情況 __STL_TEMPLATE_NULL struct hash<unsgned char> { ... };//特化unsigned char情況

=>

template<class type> struct __type_traits{ ...};//非特化情況均使用這個 template<> struct __type_traits<char> { ... };//特化char情況template<class Key> struct hash { };//非特化情況均使用這個 template<> struct hash<char> { ... };//特化char情況 template<> struct hash<unsgned char> { ... };//特化unsigned char情況

總結

以上是生活随笔為你收集整理的STL源代码分析(ch 1)组态2的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。