47.__if_not_exists语句

 1 #include <iostream>
 2 using namespace std;
 3 
 4 template<class T>
 5 class myclass
 6 {
 7 public:
 8     T t;
 9     void show(T tx)
10     {
11         cout << tx << endl;
12     }
13 };
14 
15 void main()
16 {
17     /*int num;*/
18 
19     /*__if_exists(num)
20     {
21         cout << "存在" << endl;
22     }*/
23     /*__if_not_exists(num)
24     {
25         cout << "不存在" << endl;
26     }*/
27 
28     myclass<int> t1;
29 
30     //检测某个模板有没有根据某个类型实例化
31     __if_exists(myclass<int>)
32     {
33         cout << "存在" << endl;
34     }
35     cin.get();
36 }

 

posted @ 2018-03-12 22:20  喵小喵~  阅读(468)  评论(0编辑  收藏  举报