diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-12-31 14:04:23 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-12-31 14:04:23 +0000 |
commit | 17a39b32b89798e4ba1ef832a25bd86ca675aedf (patch) | |
tree | 2a79773ed17b7602f6f869010bf6182e1021cfac /libstdc++-v3 | |
parent | 43bb43e14337f18047744476ab893f601657addb (diff) | |
download | gcc-17a39b32b89798e4ba1ef832a25bd86ca675aedf.tar.gz |
2009-12-31 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/type_traits (__is_constructible_helper1): Rename
to __is_constructible_helper1, tweaked to a specialization of
__is_constructible_helper.
(is_constructible): Adjust; minor formatting and stylistic
changes throughout.
* testsuite/util/testsuite_tr1.h (test_relationship): Change
variadic version to an overload of test_property.
* testsuite/20_util/is_constructible/value.cc: Adjust.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
Adjust dg-error line numbers.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.
* testsuite/20_util/declval/requirements/1_neg.cc: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155536 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
7 files changed, 99 insertions, 98 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a7fbfd8ddd0..4e706aa0b71 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,19 @@ +2009-12-31 Paolo Carlini <paolo.carlini@oracle.com> + + * include/std/type_traits (__is_constructible_helper1): Rename + to __is_constructible_helper1, tweaked to a specialization of + __is_constructible_helper. + (is_constructible): Adjust; minor formatting and stylistic + changes throughout. + * testsuite/util/testsuite_tr1.h (test_relationship): Change + variadic version to an overload of test_property. + * testsuite/20_util/is_constructible/value.cc: Adjust. + * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: + Adjust dg-error line numbers. + * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: + Likewise. + * testsuite/20_util/declval/requirements/1_neg.cc: Likewise. + 2009-12-30 Paolo Carlini <paolo.carlini@oracle.com> * include/std/type_traits: Fix minor formatting nit. diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 6806b138d0f..a784bee1825 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -173,6 +173,18 @@ namespace std // Member introspection. + /// is_trivial + template<typename _Tp> + struct is_trivial + : public integral_constant<bool, __is_trivial(_Tp)> + { }; + + /// is_standard_layout + template<typename _Tp> + struct is_standard_layout + : public integral_constant<bool, __is_standard_layout(_Tp)> + { }; + /// is_pod // Could use is_standard_layout && is_trivial instead of the builtin. template<typename _Tp> @@ -180,10 +192,46 @@ namespace std : public integral_constant<bool, __is_pod(_Tp)> { }; - /// is_standard_layout template<typename _Tp> - struct is_standard_layout - : public integral_constant<bool, __is_standard_layout(_Tp)> + typename add_rvalue_reference<_Tp>::type declval(); + + template<typename _Tp, typename... _Args> + class __is_constructible_helper + : public __sfinae_types + { + template<typename _Tp1, typename... __Args1> + static decltype(_Tp1(declval<__Args1>()...), __one()) __test(int); + + template<typename, typename...> + static __two __test(...); + + public: + static const bool __value = sizeof(__test<_Tp, _Args...>(0)) == 1; + }; + + template<typename _Tp, typename _Arg> + class __is_constructible_helper<_Tp, _Arg> + : public __sfinae_types + { + template<typename _Tp1, typename _Arg1> + static decltype(static_cast<_Tp1>(declval<_Arg1>()), __one()) + __test(int); + + template<typename, typename> + static __two __test(...); + + public: + static const bool __value = sizeof(__test<_Tp, _Arg>(0)) == 1; + }; + + /// is_constructible + // XXX FIXME + // The C++0x specifications require front-end support, see N2255. + template<typename _Tp, typename... _Args> + struct is_constructible + : public integral_constant<bool, + __is_constructible_helper<_Tp, + _Args...>::__value> { }; /// has_trivial_default_constructor @@ -210,12 +258,6 @@ namespace std : public integral_constant<bool, __has_trivial_destructor(_Tp)> { }; - /// is_trivial - template<typename _Tp> - struct is_trivial - : public integral_constant<bool, __is_trivial(_Tp)> - { }; - /// has_nothrow_default_constructor template<typename _Tp> struct has_nothrow_default_constructor @@ -234,16 +276,14 @@ namespace std : public integral_constant<bool, __has_nothrow_assign(_Tp)> { }; + // Relationships between types. + /// is_base_of template<typename _Base, typename _Derived> struct is_base_of : public integral_constant<bool, __is_base_of(_Base, _Derived)> { }; - template<typename _Tp> - typename add_rvalue_reference<_Tp>::type declval(); - - // Relationships between types. template<typename _From, typename _To, bool = (is_void<_From>::value || is_void<_To>::value || is_function<_To>::value || is_array<_To>::value)> @@ -252,10 +292,9 @@ namespace std && is_void<_To>::value); }; template<typename _From, typename _To> - struct __is_convertible_helper<_From, _To, false> + class __is_convertible_helper<_From, _To, false> : public __sfinae_types { - private: static __one __test(_To); static __two __test(...); @@ -263,59 +302,16 @@ namespace std static const bool __value = sizeof(__test(declval<_From>())) == 1; }; + /// is_convertible // XXX FIXME // The C++0x specifications require front-end support, see N2255. - /// is_convertible template<typename _From, typename _To> struct is_convertible : public integral_constant<bool, __is_convertible_helper<_From, _To>::__value> { }; - template<typename _To, typename... _From> - struct __is_constructible_helper - : public __sfinae_types - { - private: - template<typename _To1, typename... _From1> - static decltype(_To1(declval<_From1>()...), __one()) __test(int); - - template<typename, typename...> - static __two __test(...); - - public: - static const bool __value = sizeof(__test<_To, _From...>(0)) == 1; - }; - - template<typename _To, typename... _From> - struct is_constructible - : public integral_constant<bool, - __is_constructible_helper<_To, - _From...>::__value> - { }; - - template<typename _To, typename _From> - struct __is_constructible_helper1 - : public __sfinae_types - { - private: - template<typename _To1, typename _From1> - static decltype(static_cast<_To1>(declval<_From1>()), __one()) - __test(int); - - template<typename, typename> - static __two __test(...); - - public: - static const bool __value = sizeof(__test<_To, _From>(0)) == 1; - }; - - template<typename _To, typename _From> - struct is_constructible<_To, _From> - : public integral_constant<bool, - __is_constructible_helper1<_To, _From>::__value> - { }; - + /// is_explicitly_convertible template<typename _From, typename _To> struct is_explicitly_convertible : public is_constructible<_To, _From> @@ -401,9 +397,8 @@ namespace std /// decay template<typename _Tp> - struct decay + class decay { - private: typedef typename remove_reference<_Tp>::type __remove_type; public: @@ -434,9 +429,8 @@ namespace std template<typename _Qualified, typename _Unqualified, bool _IsConst = is_const<_Qualified>::value, bool _IsVol = is_volatile<_Qualified>::value> - struct __match_cv_qualifiers + class __match_cv_qualifiers { - private: typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; public: @@ -478,12 +472,11 @@ namespace std template<typename _Tp, bool _IsInt = is_integral<_Tp>::value, bool _IsEnum = is_enum<_Tp>::value> - struct __make_unsigned_selector; - + class __make_unsigned_selector; + template<typename _Tp> - struct __make_unsigned_selector<_Tp, true, false> + class __make_unsigned_selector<_Tp, true, false> { - private: typedef __make_unsigned<typename remove_cv<_Tp>::type> __unsignedt; typedef typename __unsignedt::__type __unsigned_type; typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned; @@ -493,9 +486,8 @@ namespace std }; template<typename _Tp> - struct __make_unsigned_selector<_Tp, false, true> + class __make_unsigned_selector<_Tp, false, true> { - private: // With -fshort-enums, an enum may be as small as a char. typedef unsigned char __smallest; static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest); @@ -557,12 +549,11 @@ namespace std template<typename _Tp, bool _IsInt = is_integral<_Tp>::value, bool _IsEnum = is_enum<_Tp>::value> - struct __make_signed_selector; - + class __make_signed_selector; + template<typename _Tp> - struct __make_signed_selector<_Tp, true, false> + class __make_signed_selector<_Tp, true, false> { - private: typedef __make_signed<typename remove_cv<_Tp>::type> __signedt; typedef typename __signedt::__type __signed_type; typedef __match_cv_qualifiers<_Tp, __signed_type> __cv_signed; @@ -572,9 +563,8 @@ namespace std }; template<typename _Tp> - struct __make_signed_selector<_Tp, false, true> + class __make_signed_selector<_Tp, false, true> { - private: // With -fshort-enums, an enum may be as small as a char. typedef signed char __smallest; static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest); diff --git a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc index dfb522e819d..59b90961398 100644 --- a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc +++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc @@ -19,7 +19,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-error "static assertion failed" "" { target *-*-* } 636 } +// { dg-error "static assertion failed" "" { target *-*-* } 626 } // { dg-error "instantiated from here" "" { target *-*-* } 30 } // { dg-excess-errors "In function" } diff --git a/libstdc++-v3/testsuite/20_util/is_constructible/value.cc b/libstdc++-v3/testsuite/20_util/is_constructible/value.cc index 5ff57f6fb6b..280710bebea 100644 --- a/libstdc++-v3/testsuite/20_util/is_constructible/value.cc +++ b/libstdc++-v3/testsuite/20_util/is_constructible/value.cc @@ -28,16 +28,13 @@ void test01() using namespace __gnu_test; // Positive tests. - VERIFY( (test_relationship<is_constructible, ExplicitClass, - double&>(true)) ); - VERIFY( (test_relationship<is_constructible, ExplicitClass, - int&>(true)) ); + VERIFY( (test_property<is_constructible, ExplicitClass, double&>(true)) ); + VERIFY( (test_property<is_constructible, ExplicitClass, int&>(true)) ); // Negative tests. - VERIFY( (test_relationship<is_constructible, ExplicitClass, - void*>(false)) ); - VERIFY( (test_relationship<is_constructible, ExplicitClass>(false)) ); - VERIFY( (test_relationship<is_constructible, ExplicitClass, + VERIFY( (test_property<is_constructible, ExplicitClass, void*>(false)) ); + VERIFY( (test_property<is_constructible, ExplicitClass>(false)) ); + VERIFY( (test_property<is_constructible, ExplicitClass, int, double>(false)) ); } diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc index b37963330c4..eec74c71593 100644 --- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -48,8 +48,8 @@ void test01() // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 598 } -// { dg-error "declaration of" "" { target *-*-* } 560 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 588 } +// { dg-error "declaration of" "" { target *-*-* } 552 } // { dg-excess-errors "At global scope" } // { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc index 0b842b39ea3..708482ef8a3 100644 --- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -48,8 +48,8 @@ void test01() // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 519 } -// { dg-error "declaration of" "" { target *-*-* } 481 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 511 } +// { dg-error "declaration of" "" { target *-*-* } 475 } // { dg-excess-errors "At global scope" } // { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/util/testsuite_tr1.h b/libstdc++-v3/testsuite/util/testsuite_tr1.h index 7ac45bdcaa0..aecf56220e0 100644 --- a/libstdc++-v3/testsuite/util/testsuite_tr1.h +++ b/libstdc++-v3/testsuite/util/testsuite_tr1.h @@ -56,8 +56,7 @@ namespace __gnu_test // For testing tr1/type_traits/extent, which has a second template // parameter. template<template<typename, unsigned> class Property, - typename Type, - unsigned Uint> + typename Type, unsigned Uint> bool test_property(typename Property<Type, Uint>::value_type value) { @@ -68,17 +67,17 @@ namespace __gnu_test } #ifdef __GXX_EXPERIMENTAL_CXX0X__ - template<template<typename...> class Relationship, - typename... Types> + template<template<typename...> class Property, typename... Types> bool - test_relationship(bool value) + test_property(typename Property<Types...>::value_type value) { bool ret = true; - ret &= Relationship<Types...>::value == value; - ret &= Relationship<Types...>::type::value == value; + ret &= Property<Types...>::value == value; + ret &= Property<Types...>::type::value == value; return ret; } -#else +#endif + template<template<typename, typename> class Relationship, typename Type1, typename Type2> bool @@ -89,7 +88,6 @@ namespace __gnu_test ret &= Relationship<Type1, Type2>::type::value == value; return ret; } -#endif // Test types. class ClassType { }; |