日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

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

發布時間:2025/3/21 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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的全部內容,希望文章能夠幫你解決所遇到的問題。

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