diff options
Diffstat (limited to 'test/SemaTemplate/temp_class_spec.cpp')
| -rw-r--r-- | test/SemaTemplate/temp_class_spec.cpp | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/test/SemaTemplate/temp_class_spec.cpp b/test/SemaTemplate/temp_class_spec.cpp index 4e4f5560aef3..1a534236c8eb 100644 --- a/test/SemaTemplate/temp_class_spec.cpp +++ b/test/SemaTemplate/temp_class_spec.cpp @@ -134,3 +134,130 @@ int is_unary_function6[is_unary_function_with_same_return_type_as_argument_type< int is_unary_function7[is_unary_function_with_same_return_type_as_argument_type<int (*)(int, bool)>::value ? -1 : 1]; int is_unary_function8[is_unary_function_with_same_return_type_as_argument_type<int (*)(bool)>::value ? -1 : 1]; int is_unary_function9[is_unary_function_with_same_return_type_as_argument_type<int (*)(int)>::value ? 1 : -1]; +int is_unary_function10[is_unary_function_with_same_return_type_as_argument_type<int (*)(int, ...)>::value ? -1 : 1]; +int is_unary_function11[is_unary_function_with_same_return_type_as_argument_type<int (* const)(int)>::value ? -1 : 1]; + +template<typename T> +struct is_binary_function { + static const bool value = false; +}; + +template<typename R, typename T1, typename T2> +struct is_binary_function<R(T1, T2)> { + static const bool value = true; +}; + +int is_binary_function0[is_binary_function<int(float, double)>::value? 1 : -1]; + +template<typename T> +struct is_member_pointer { + static const bool value = false; +}; + +template<typename T, typename Class> +struct is_member_pointer<T Class::*> { + static const bool value = true; +}; + +struct X { }; + +int is_member_pointer0[is_member_pointer<int X::*>::value? 1 : -1]; +int is_member_pointer1[is_member_pointer<const int X::*>::value? 1 : -1]; +int is_member_pointer2[is_member_pointer<int (X::*)()>::value? 1 : -1]; +int is_member_pointer3[is_member_pointer<int (X::*)(int) const>::value? 1 : -1]; +int is_member_pointer4[is_member_pointer<int (X::**)(int) const>::value? -1 : 1]; +int is_member_pointer5[is_member_pointer<int>::value? -1 : 1]; + +template<typename T> +struct is_member_function_pointer { + static const bool value = false; +}; + +template<typename T, typename Class> +struct is_member_function_pointer<T (Class::*)()> { + static const bool value = true; +}; + +template<typename T, typename Class> +struct is_member_function_pointer<T (Class::*)() const> { + static const bool value = true; +}; + +template<typename T, typename Class> +struct is_member_function_pointer<T (Class::*)() volatile> { + static const bool value = true; +}; + +template<typename T, typename Class> +struct is_member_function_pointer<T (Class::*)() const volatile> { + static const bool value = true; +}; + +template<typename T, typename Class, typename A1> +struct is_member_function_pointer<T (Class::*)(A1)> { + static const bool value = true; +}; + +template<typename T, typename Class, typename A1> +struct is_member_function_pointer<T (Class::*)(A1) const> { + static const bool value = true; +}; + +template<typename T, typename Class, typename A1> +struct is_member_function_pointer<T (Class::*)(A1) volatile> { + static const bool value = true; +}; + +template<typename T, typename Class, typename A1> +struct is_member_function_pointer<T (Class::*)(A1) const volatile> { + static const bool value = true; +}; + +int is_member_function_pointer0[ + is_member_function_pointer<int X::*>::value? -1 : 1]; +int is_member_function_pointer1[ + is_member_function_pointer<int (X::*)()>::value? 1 : -1]; +int is_member_function_pointer2[ + is_member_function_pointer<X (X::*)(X&)>::value? 1 : -1]; +int is_member_function_pointer3[ + is_member_function_pointer<int (X::*)() const>::value? 1 : -1]; +int is_member_function_pointer4[ + is_member_function_pointer<int (X::*)(float) const>::value? 1 : -1]; + +// Test substitution of non-dependent arguments back into the template +// argument list of the class template partial specialization. +template<typename T, typename ValueType = T> +struct is_nested_value_type_identity { + static const bool value = false; +}; + +template<typename T> +struct is_nested_value_type_identity<T, typename T::value_type> { + static const bool value = true; +}; + +template<typename T> +struct HasValueType { + typedef T value_type; +}; + +struct HasIdentityValueType { + typedef HasIdentityValueType value_type; +}; + +struct NoValueType { }; + +int is_nested_value_type_identity0[ + is_nested_value_type_identity<HasValueType<int> >::value? -1 : 1]; +int is_nested_value_type_identity1[ + is_nested_value_type_identity<HasIdentityValueType>::value? 1 : -1]; +int is_nested_value_type_identity2[ + is_nested_value_type_identity<NoValueType>::value? -1 : 1]; + + +// C++ [temp.class.spec]p4: +template<class T1, class T2, int I> class A { }; //#1 +template<class T, int I> class A<T, T*, I> { }; //#2 +template<class T1, class T2, int I> class A<T1*, T2, I> { }; //#3 +template<class T> class A<int, T*, 5> { }; //#4 +template<class T1, class T2, int I> class A<T1, T2*, I> { }; //#5 |
