1. __STL_STATIC_TEMPLATE_MEMBER_BUG
static member of template classes(模板类静态成员)
template <typename T>
class test{
public:
static int _data;
}
int test<int>::_data=1;
int test<char>::_data=2;
2. __STL_CLASS_PARTIAL_SPECIALIZATION
模板类偏特化,是否支持 partial specialization of class templates
//一般化设计,非特化情况均使用这个
template <class I,class O>
struct test{
test() {
cout << "I, O" <<endl; }
};
//特殊化设计1(偏特化1)
template <class T>
struct test <T* ,T*> {
test() {
cout << "T* ,T*" << endl; }
};
//特殊化设计2(偏特化2)
template <class T>
struct test <const T* ,T*> {
test() {
cout << "const T* ,T*" << endl; }
};
//测试
int main() {
test<int, char> obj1; //I, O
test<int*, int*> obj2; //T*, T*
test<const int*, int*> obj3; //const T*, T*
}
3. __STL_FUNCTION_TMPL_PARTIAL_ORDER
是否支持partial ordering of function templates
template <class T,class Alloc=alloc>
class vec {
public:
void swap(vec<T, Alloc>&) {
cout << "swap1()" << endl; }
};
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
template <class T, class Alloc = alloc>
inline void swap(vec<T, Alloc>& a, vec<T, Alloc>& b) {
a.swap(b); }
#endif
int main() {
vec<int> a, b;
swap(a, b);
}