From 17a39b32b89798e4ba1ef832a25bd86ca675aedf Mon Sep 17 00:00:00 2001 From: paolo Date: Thu, 31 Dec 2009 14:04:23 +0000 Subject: 2009-12-31 Paolo Carlini * 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 --- libstdc++-v3/ChangeLog | 16 +++ libstdc++-v3/include/std/type_traits | 142 ++++++++++----------- .../20_util/declval/requirements/1_neg.cc | 2 +- .../testsuite/20_util/is_constructible/value.cc | 13 +- .../make_signed/requirements/typedefs_neg.cc | 4 +- .../make_unsigned/requirements/typedefs_neg.cc | 4 +- libstdc++-v3/testsuite/util/testsuite_tr1.h | 16 +-- 7 files changed, 99 insertions(+), 98 deletions(-) (limited to 'libstdc++-v3') 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 + + * 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 * 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 + struct is_trivial + : public integral_constant + { }; + + /// is_standard_layout + template + struct is_standard_layout + : public integral_constant + { }; + /// is_pod // Could use is_standard_layout && is_trivial instead of the builtin. template @@ -180,10 +192,46 @@ namespace std : public integral_constant { }; - /// is_standard_layout template - struct is_standard_layout - : public integral_constant + typename add_rvalue_reference<_Tp>::type declval(); + + template + class __is_constructible_helper + : public __sfinae_types + { + template + static decltype(_Tp1(declval<__Args1>()...), __one()) __test(int); + + template + static __two __test(...); + + public: + static const bool __value = sizeof(__test<_Tp, _Args...>(0)) == 1; + }; + + template + class __is_constructible_helper<_Tp, _Arg> + : public __sfinae_types + { + template + static decltype(static_cast<_Tp1>(declval<_Arg1>()), __one()) + __test(int); + + template + 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 + struct is_constructible + : public integral_constant::__value> { }; /// has_trivial_default_constructor @@ -210,12 +258,6 @@ namespace std : public integral_constant { }; - /// is_trivial - template - struct is_trivial - : public integral_constant - { }; - /// has_nothrow_default_constructor template struct has_nothrow_default_constructor @@ -234,16 +276,14 @@ namespace std : public integral_constant { }; + // Relationships between types. + /// is_base_of template struct is_base_of : public integral_constant { }; - template - typename add_rvalue_reference<_Tp>::type declval(); - - // Relationships between types. template::value || is_void<_To>::value || is_function<_To>::value || is_array<_To>::value)> @@ -252,10 +292,9 @@ namespace std && is_void<_To>::value); }; template - 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 struct is_convertible : public integral_constant::__value> { }; - template - struct __is_constructible_helper - : public __sfinae_types - { - private: - template - static decltype(_To1(declval<_From1>()...), __one()) __test(int); - - template - static __two __test(...); - - public: - static const bool __value = sizeof(__test<_To, _From...>(0)) == 1; - }; - - template - struct is_constructible - : public integral_constant::__value> - { }; - - template - struct __is_constructible_helper1 - : public __sfinae_types - { - private: - template - static decltype(static_cast<_To1>(declval<_From1>()), __one()) - __test(int); - - template - static __two __test(...); - - public: - static const bool __value = sizeof(__test<_To, _From>(0)) == 1; - }; - - template - struct is_constructible<_To, _From> - : public integral_constant::__value> - { }; - + /// is_explicitly_convertible template struct is_explicitly_convertible : public is_constructible<_To, _From> @@ -401,9 +397,8 @@ namespace std /// decay template - struct decay + class decay { - private: typedef typename remove_reference<_Tp>::type __remove_type; public: @@ -434,9 +429,8 @@ namespace std template::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::value, bool _IsEnum = is_enum<_Tp>::value> - struct __make_unsigned_selector; - + class __make_unsigned_selector; + template - struct __make_unsigned_selector<_Tp, true, false> + class __make_unsigned_selector<_Tp, true, false> { - private: typedef __make_unsigned::type> __unsignedt; typedef typename __unsignedt::__type __unsigned_type; typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned; @@ -493,9 +486,8 @@ namespace std }; template - 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::value, bool _IsEnum = is_enum<_Tp>::value> - struct __make_signed_selector; - + class __make_signed_selector; + template - struct __make_signed_selector<_Tp, true, false> + class __make_signed_selector<_Tp, true, false> { - private: typedef __make_signed::type> __signedt; typedef typename __signedt::__type __signed_type; typedef __match_cv_qualifiers<_Tp, __signed_type> __cv_signed; @@ -572,9 +563,8 @@ namespace std }; template - 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 // . -// { 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(true)) ); - VERIFY( (test_relationship(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); // Negative tests. - VERIFY( (test_relationship(false)) ); - VERIFY( (test_relationship(false)) ); - VERIFY( (test_relationship(false)) ); + VERIFY( (test_property(false)) ); + VERIFY( (test_property(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 class Property, - typename Type, - unsigned Uint> + typename Type, unsigned Uint> bool test_property(typename Property::value_type value) { @@ -68,17 +67,17 @@ namespace __gnu_test } #ifdef __GXX_EXPERIMENTAL_CXX0X__ - template class Relationship, - typename... Types> + template class Property, typename... Types> bool - test_relationship(bool value) + test_property(typename Property::value_type value) { bool ret = true; - ret &= Relationship::value == value; - ret &= Relationship::type::value == value; + ret &= Property::value == value; + ret &= Property::type::value == value; return ret; } -#else +#endif + template class Relationship, typename Type1, typename Type2> bool @@ -89,7 +88,6 @@ namespace __gnu_test ret &= Relationship::type::value == value; return ret; } -#endif // Test types. class ClassType { }; -- cgit v1.2.1