Douglas Gregor | 58944ac | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
| 2 | template<typename T> |
| 3 | struct is_pointer { |
| 4 | static const bool value = false; |
| 5 | }; |
| 6 | |
| 7 | template<typename T> |
| 8 | struct is_pointer<T*> { |
| 9 | static const bool value = true; |
| 10 | }; |
| 11 | |
| 12 | template<typename T> |
| 13 | struct is_pointer<const T*> { |
| 14 | static const bool value = true; |
| 15 | }; |
| 16 | |
| 17 | int array0[is_pointer<int>::value? -1 : 1]; |
| 18 | int array1[is_pointer<int*>::value? 1 : -1]; |
| 19 | int array2[is_pointer<const int*>::value? 1 : -1]; // expected-error{{partial ordering}} \ |
| 20 | // expected-error{{negative}} |
Douglas Gregor | bf23a8a | 2009-06-04 00:03:07 +0000 | [diff] [blame] | 21 | |
| 22 | template<typename T, typename U> |
| 23 | struct is_same { |
| 24 | static const bool value = false; |
| 25 | }; |
| 26 | |
| 27 | template<typename T> |
| 28 | struct is_same<T, T> { |
| 29 | static const bool value = true; |
| 30 | }; |
| 31 | |
| 32 | typedef int INT; |
| 33 | typedef INT* int_ptr; |
| 34 | |
| 35 | int is_same0[is_same<int, int>::value? 1 : -1]; |
| 36 | int is_same1[is_same<int, INT>::value? 1 : -1]; |
| 37 | int is_same2[is_same<const int, int>::value? -1 : 1]; |
| 38 | int is_same3[is_same<int_ptr, int>::value? -1 : 1]; |