diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-06-05 00:53:49 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-06-05 00:53:49 +0000 |
commit | 199d99192fbcca9f043596c40ead4afab4999dba (patch) | |
tree | 14716988cdd0af1ae955782954af60f098390770 /test/SemaTemplate/temp_class_spec.cpp | |
parent | 29b1d07a87a2038ae5b4128a0b534badd728707d (diff) |
Several improvements to template argument deduction:
- Once we have deduced template arguments for a class template partial
specialization, we use exactly those template arguments for instantiating
the definition of the class template partial specialization.
- Added template argument deduction for non-type template parameters.
- Added template argument deduction for dependently-sized array types.
With these changes, we can now implement, e.g., the remove_reference
type trait. Also, Daniel's Ackermann template metaprogram now compiles
properly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72909 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate/temp_class_spec.cpp')
-rw-r--r-- | test/SemaTemplate/temp_class_spec.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/SemaTemplate/temp_class_spec.cpp b/test/SemaTemplate/temp_class_spec.cpp index d516f01d7f..8cb46cf98f 100644 --- a/test/SemaTemplate/temp_class_spec.cpp +++ b/test/SemaTemplate/temp_class_spec.cpp @@ -51,6 +51,19 @@ int is_same2[is_same<const int, int>::value? -1 : 1]; int is_same3[is_same<int_ptr, int>::value? -1 : 1]; template<typename T> +struct remove_reference { + typedef T type; +}; + +template<typename T> +struct remove_reference<T&> { + typedef T type; +}; + +int remove_ref0[is_same<remove_reference<int>::type, int>::value? 1 : -1]; +int remove_ref1[is_same<remove_reference<int&>::type, int>::value? 1 : -1]; + +template<typename T> struct is_incomplete_array { static const bool value = false; }; @@ -79,3 +92,13 @@ int array_with_4_elements0[is_array_with_4_elements<int[]>::value ? -1 : 1]; int array_with_4_elements1[is_array_with_4_elements<int[1]>::value ? -1 : 1]; int array_with_4_elements2[is_array_with_4_elements<int[4]>::value ? 1 : -1]; int array_with_4_elements3[is_array_with_4_elements<int[4][2]>::value ? 1 : -1]; + +template<typename T> +struct get_array_size; + +template<typename T, unsigned N> +struct get_array_size<T[N]> { + static const unsigned value = N; +}; + +int array_size0[get_array_size<int[12]>::value == 12? 1 : -1]; |