type_traits (is_convertible): Adjust according to the resolution of TR1 issue 3.20.

2005-04-29  Paolo Carlini  <pcarlini@suse.de>

	* include/tr1/type_traits (is_convertible): Adjust according
	to the resolution of TR1 issue 3.20.
	* testsuite/tr1/4_metaprogramming/relationships_between_types/
	is_convertible/is_convertible.cc: Add tests.

From-SVN: r98944
This commit is contained in:
Paolo Carlini 2005-04-28 22:35:09 +00:00 committed by Paolo Carlini
parent 973a384d4f
commit 152d96766a
3 changed files with 21 additions and 3 deletions

View File

@ -1,3 +1,10 @@
2005-04-29 Paolo Carlini <pcarlini@suse.de>
* include/tr1/type_traits (is_convertible): Adjust according
to the resolution of TR1 issue 3.20.
* testsuite/tr1/4_metaprogramming/relationships_between_types/
is_convertible/is_convertible.cc: Add tests.
2005-04-28 Paolo Carlini <pcarlini@suse.de>
Gabriel Dos Reis <gdr@integrable-solutions.net>

View File

@ -501,7 +501,8 @@ namespace tr1
};
template<typename _From, typename _To,
bool = (is_function<_To>::value || is_array<_To>::value
bool = (is_void<_From>::value || is_void<_To>::value
|| is_function<_To>::value || is_array<_To>::value
// This special case is here only to avoid warnings.
|| (is_floating_point<typename
remove_reference<_From>::type>::value
@ -515,7 +516,9 @@ namespace tr1
template<typename _From, typename _To>
struct __is_convertible_helper<_From, _To, true>
{ static const bool __value = __is_int_or_cref<_To>::__value; };
{ static const bool __value = (is_void<_To>::value
|| (__is_int_or_cref<_To>::__value
&& !is_void<_From>::value)); };
template<typename _From, typename _To>
struct is_convertible

View File

@ -54,6 +54,10 @@ void test01()
VERIFY( (test_relationship<is_convertible, DerivedType*, ClassType*>(true)) );
VERIFY( (test_relationship<is_convertible, DerivedType&, ClassType&>(true)) );
VERIFY( (test_relationship<is_convertible, void, void>(true)) );
VERIFY( (test_relationship<is_convertible, int, void>(true)) );
VERIFY( (test_relationship<is_convertible, int[4], void>(true)) );
// Negative tests.
VERIFY( (test_relationship<is_convertible, const int*, int*>(false)) );
VERIFY( (test_relationship<is_convertible, int*, float*>(false)) );
@ -69,7 +73,11 @@ void test01()
VERIFY( (test_relationship<is_convertible, int, ClassType>(false)) );
VERIFY( (test_relationship<is_convertible, ClassType, DerivedType>(false)) );
VERIFY( (test_relationship<is_convertible, ClassType*, DerivedType*>(false)) );
VERIFY( (test_relationship<is_convertible, ClassType&, DerivedType&>(false)) );
VERIFY( (test_relationship<is_convertible, ClassType&, DerivedType&>(false)) );
VERIFY( (test_relationship<is_convertible, void, int>(false)) );
VERIFY( (test_relationship<is_convertible, void, float>(false)) );
VERIFY( (test_relationship<is_convertible, void, int(*)(int)>(false)) );
}
int main()