summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-09 17:07:37 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-09 17:07:37 +0000
commit6be2333a3345cc46e745db7280c1bfc2c1326018 (patch)
tree0c08230ec70b696c8b3ac9ea29297b04a72bf12c /libstdc++-v3
parentd9745cea0edd0db7c11861860449a97e00dcb575 (diff)
downloadppe42-gcc-6be2333a3345cc46e745db7280c1bfc2c1326018.tar.gz
ppe42-gcc-6be2333a3345cc46e745db7280c1bfc2c1326018.zip
2007-04-09 Paolo Carlini <pcarlini@suse.de>
* include/tr1/type_traits_fwd.h (__is_union_or_class): Remove. * include/tr1/type_traits (struct __in_array, struct __is_union_or_class, struct __is_union_or_class_helper, struct __is_empty_helper, struct __is_polymorphic_helper): Remove. (struct is_enum): Use __is_enum. (struct is_union): Use __is_union. (struct is_class): Use __is_class. (struct is_function): Adjust. (struct is_empty): Use __is_empty. (struct is_polymorphic): Use __is_polymorphic. (struct is_abstract): Use __is_abstract. (struct has_virtual_destructor): Use __has_virtual_destructor. (struct __is_base_of_helper): Use __is_base_of. * testsuite/tr1/4_metaprogramming/composite_type_traits/ is_union_or_class/typedefs.cc: Remove. * testsuite/tr1/4_metaprogramming/composite_type_traits/ is_union_or_class/is_union_or_class.cc: Likewise. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_class/typedefs.cc: New. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_class/is_class.cc: Likewise. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_union/typedefs.cc: Likewise. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_union/is_union.cc: Likewise. * testsuite/tr1/4_metaprogramming/type_properties/ has_virtual_destructor/typedefs.cc: Likewise. * testsuite/tr1/4_metaprogramming/type_properties/ has_virtual_destructor/has_virtual_destructor.cc: Likewise. * testsuite/util/testsuite_tr1.h (class VirtualDestructorClass): Add. * testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/ is_polymorphic.cc: Add test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123675 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog36
-rw-r--r--libstdc++-v3/include/tr1/type_traits159
-rw-r--r--libstdc++-v3/include/tr1/type_traits_fwd.h6
-rw-r--r--libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/is_union_or_class.cc62
-rw-r--r--libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_class/is_class.cc61
-rw-r--r--libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_class/typedefs.cc (renamed from libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/typedefs.cc)6
-rw-r--r--libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_union/is_union.cc61
-rw-r--r--libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_union/typedefs.cc36
-rw-r--r--libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/has_virtual_destructor/has_virtual_destructor.cc56
-rw-r--r--libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/has_virtual_destructor/typedefs.cc36
-rw-r--r--libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/is_polymorphic.cc3
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_tr1.h9
12 files changed, 329 insertions, 202 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 8785968d9fb..f180ad7c4b4 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,39 @@
+2007-04-09 Paolo Carlini <pcarlini@suse.de>
+
+ * include/tr1/type_traits_fwd.h (__is_union_or_class): Remove.
+ * include/tr1/type_traits (struct __in_array,
+ struct __is_union_or_class, struct __is_union_or_class_helper,
+ struct __is_empty_helper, struct __is_polymorphic_helper):
+ Remove.
+ (struct is_enum): Use __is_enum.
+ (struct is_union): Use __is_union.
+ (struct is_class): Use __is_class.
+ (struct is_function): Adjust.
+ (struct is_empty): Use __is_empty.
+ (struct is_polymorphic): Use __is_polymorphic.
+ (struct is_abstract): Use __is_abstract.
+ (struct has_virtual_destructor): Use __has_virtual_destructor.
+ (struct __is_base_of_helper): Use __is_base_of.
+ * testsuite/tr1/4_metaprogramming/composite_type_traits/
+ is_union_or_class/typedefs.cc: Remove.
+ * testsuite/tr1/4_metaprogramming/composite_type_traits/
+ is_union_or_class/is_union_or_class.cc: Likewise.
+ * testsuite/tr1/4_metaprogramming/primary_type_categories/
+ is_class/typedefs.cc: New.
+ * testsuite/tr1/4_metaprogramming/primary_type_categories/
+ is_class/is_class.cc: Likewise.
+ * testsuite/tr1/4_metaprogramming/primary_type_categories/
+ is_union/typedefs.cc: Likewise.
+ * testsuite/tr1/4_metaprogramming/primary_type_categories/
+ is_union/is_union.cc: Likewise.
+ * testsuite/tr1/4_metaprogramming/type_properties/
+ has_virtual_destructor/typedefs.cc: Likewise.
+ * testsuite/tr1/4_metaprogramming/type_properties/
+ has_virtual_destructor/has_virtual_destructor.cc: Likewise.
+ * testsuite/util/testsuite_tr1.h (class VirtualDestructorClass): Add.
+ * testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/
+ is_polymorphic.cc: Add test.
+
2007-04-08 Alexey Beshenov <bav.272304@gmail.com>
PR libstdc++/31511
diff --git a/libstdc++-v3/include/tr1/type_traits b/libstdc++-v3/include/tr1/type_traits
index 996ecf6fd93..c29701c8de0 100644
--- a/libstdc++-v3/include/tr1/type_traits
+++ b/libstdc++-v3/include/tr1/type_traits
@@ -1,6 +1,6 @@
// TR1 type_traits -*- C++ -*-
-// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -42,27 +42,13 @@ namespace std
{
_GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
- // For use in __in_array and elsewhere.
+ // For use in __is_convertible_simple.
struct __sfinae_types
{
typedef char __one;
typedef struct { char __arr[2]; } __two;
};
- template<typename _Tp>
- struct __in_array
- : public __sfinae_types
- {
- private:
- template<typename _Up>
- static __one __test(_Up(*)[1]);
- template<typename>
- static __two __test(...);
-
- public:
- static const bool __value = sizeof(__test<_Tp>(0)) == 1;
- };
-
#define _DEFINE_SPEC_BODY(_Value) \
: public integral_constant<bool, _Value> { };
@@ -172,27 +158,27 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
template<typename _Tp>
struct is_enum
- : public integral_constant<bool, !(is_fundamental<_Tp>::value
- || is_array<_Tp>::value
- || is_pointer<_Tp>::value
- || is_reference<_Tp>::value
- || is_member_pointer<_Tp>::value
- || is_function<_Tp>::value
- || __is_union_or_class<_Tp>::value)>
+ : public integral_constant<bool, __is_enum(_Tp)>
{ };
- template<typename>
- struct is_union { };
+ template<typename _Tp>
+ struct is_union
+ : public integral_constant<bool, __is_union(_Tp)>
+ { };
- template<typename>
- struct is_class { };
+ template<typename _Tp>
+ struct is_class
+ : public integral_constant<bool, __is_class(_Tp)>
+ { };
template<typename _Tp>
struct is_function
- : public integral_constant<bool, !(__in_array<_Tp>::__value
- || __is_union_or_class<_Tp>::value
+ : public integral_constant<bool, !(is_void<_Tp>::value
+ || is_scalar<_Tp>::value
+ || is_array<_Tp>::value
|| is_reference<_Tp>::value
- || is_void<_Tp>::value)>
+ || is_union<_Tp>::value
+ || is_class<_Tp>::value)>
{ };
/// @brief composite type traits [4.5.2].
@@ -234,26 +220,6 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
|| is_member_function_pointer<_Tp>::value)>
{ };
- template<typename _Tp>
- struct __is_union_or_class_helper
- : public __sfinae_types
- {
- private:
- template<typename _Up>
- static __one __test(int _Up::*);
- template<typename>
- static __two __test(...);
-
- public:
- static const bool __value = sizeof(__test<_Tp>(0)) == 1;
- };
-
- // Extension.
- template<typename _Tp>
- struct __is_union_or_class
- : public integral_constant<bool, __is_union_or_class_helper<_Tp>::__value>
- { };
-
/// @brief type properties [4.5.3].
template<typename>
struct is_const
@@ -278,64 +244,20 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
remove_all_extents<_Tp>::type>::value)>
{ };
- // NB: Without compiler support we cannot tell union from class types,
- // and is_empty and is_polymorphic don't work at all with the former.
- template<typename _Tp, bool = !__is_union_or_class<_Tp>::value>
- struct __is_empty_helper
- {
- private:
- template<typename>
- struct __first { };
- template<typename _Up>
- struct __second
- : public _Up { };
-
- public:
- static const bool __value = sizeof(__first<_Tp>) == sizeof(__second<_Tp>);
- };
-
- template<typename _Tp>
- struct __is_empty_helper<_Tp, true>
- { static const bool __value = false; };
-
template<typename _Tp>
struct is_empty
- : public integral_constant<bool, __is_empty_helper<_Tp>::__value>
+ : public integral_constant<bool, __is_empty(_Tp)>
{ };
- template<typename _Tp, bool = !__is_union_or_class<_Tp>::value>
- struct __is_polymorphic_helper
- {
- private:
- template<typename _Up>
- struct __first
- : public _Up { };
- template<typename _Up>
- struct __second
- : public _Up
- {
- virtual void __dummy();
- virtual ~__second() throw();
- };
-
- public:
- static const bool __value = sizeof(__first<_Tp>) == sizeof(__second<_Tp>);
- };
-
- template<typename _Tp>
- struct __is_polymorphic_helper<_Tp, true>
- { static const bool __value = false; };
-
template<typename _Tp>
struct is_polymorphic
- : public integral_constant<bool, __is_polymorphic_helper<_Tp>::__value>
+ : public integral_constant<bool, __is_polymorphic(_Tp)>
{ };
- // Exploit the resolution DR core/337.
template<typename _Tp>
struct is_abstract
- : public integral_constant<bool, (!__in_array<_Tp>::__value
- && __is_union_or_class<_Tp>::value)> { };
+ : public integral_constant<bool, __is_abstract(_Tp)>
+ { };
template<typename _Tp>
struct has_trivial_constructor
@@ -365,9 +287,10 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
struct has_nothrow_assign
: public integral_constant<bool, is_pod<_Tp>::value> { };
- template<typename>
+ template<typename _Tp>
struct has_virtual_destructor
- : public false_type { };
+ : public integral_constant<bool, __has_virtual_destructor(_Tp)>
+ { };
template<typename>
struct is_signed
@@ -430,37 +353,17 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
struct is_same<_Tp, _Tp>
: public true_type { };
- // See Daveed Vandevoorde explanation in http://tinyurl.com/502f.
- // Also see Rani Sharoni in http://tinyurl.com/6jvyq.
- template<typename _Base, typename _Derived,
- bool = (!__is_union_or_class<_Base>::value
- || !__is_union_or_class<_Derived>::value
- || is_same<_Base, _Derived>::value)>
+ template<typename _Base, typename _Derived>
struct __is_base_of_helper
- : public __sfinae_types
{
- private:
- typedef typename remove_cv<_Base>::type _NoCv_Base;
- typedef typename remove_cv<_Derived>::type _NoCv_Derived;
-
- template<typename _Up>
- static __one __test(_NoCv_Derived&, _Up);
- static __two __test(_NoCv_Base&, int);
-
- struct _Conv
- {
- operator _NoCv_Derived&();
- operator _NoCv_Base&() const;
- };
-
- public:
- static const bool __value = sizeof(__test(_Conv(), 0)) == 1;
+ typedef typename remove_cv<_Base>::type _NoCv_Base;
+ typedef typename remove_cv<_Derived>::type _NoCv_Derived;
+ static const bool __value = (is_same<_Base, _Derived>::value
+ || (__is_base_of(_Base, _Derived)
+ && !is_same<_NoCv_Base,
+ _NoCv_Derived>::value));
};
-
- template<typename _Base, typename _Derived>
- struct __is_base_of_helper<_Base, _Derived, true>
- { static const bool __value = is_same<_Base, _Derived>::value; };
-
+
template<typename _Base, typename _Derived>
struct is_base_of
: public integral_constant<bool,
diff --git a/libstdc++-v3/include/tr1/type_traits_fwd.h b/libstdc++-v3/include/tr1/type_traits_fwd.h
index 6f8e71a0c32..c6e80a3a4b9 100644
--- a/libstdc++-v3/include/tr1/type_traits_fwd.h
+++ b/libstdc++-v3/include/tr1/type_traits_fwd.h
@@ -1,6 +1,6 @@
// TR1 type_traits -*- C++ -*-
-// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -104,10 +104,6 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
template<typename _Tp>
struct is_member_pointer;
- // Extension.
- template<typename _Tp>
- struct __is_union_or_class;
-
/// @brief type properties [4.5.3].
template<typename _Tp>
struct is_const;
diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/is_union_or_class.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/is_union_or_class.cc
deleted file mode 100644
index 82c727d1ce8..00000000000
--- a/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/is_union_or_class.cc
+++ /dev/null
@@ -1,62 +0,0 @@
-// 2005-02-25 Paolo Carlini <pcarlini@suse.de>
-//
-// Copyright (C) 2005 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 2, or (at your option)
-// any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 4.5.2 Composite type traits
-
-#include <tr1/type_traits>
-#include <testsuite_hooks.h>
-#include <testsuite_tr1.h>
-
-void test01()
-{
- bool test __attribute__((unused)) = true;
- using std::tr1::__is_union_or_class;
- using namespace __gnu_test;
-
- // Positive tests.
- VERIFY( (test_category<__is_union_or_class, UnionType>(true)) );
- VERIFY( (test_category<__is_union_or_class, ClassType>(true)) );
- VERIFY( (test_category<__is_union_or_class, DerivedType>(true)) );
- VERIFY( (test_category<__is_union_or_class, ConvType>(true)) );
- VERIFY( (test_category<__is_union_or_class, AbstractClass>(true)) );
- VERIFY( (test_category<__is_union_or_class, PolymorphicClass>(true)) );
- VERIFY( (test_category<__is_union_or_class, DerivedPolymorphic>(true)) );
-
- // Negative tests.
- VERIFY( (test_category<__is_union_or_class, void>(false)) );
- VERIFY( (test_category<__is_union_or_class, int>(false)) );
- VERIFY( (test_category<__is_union_or_class, float>(false)) );
- VERIFY( (test_category<__is_union_or_class, int[2]>(false)) );
- VERIFY( (test_category<__is_union_or_class, int*>(false)) );
- VERIFY( (test_category<__is_union_or_class, int(*)(int)>(false)) );
- VERIFY( (test_category<__is_union_or_class, float&>(false)) );
- VERIFY( (test_category<__is_union_or_class, float(&)(float)>(false)) );
- VERIFY( (test_category<__is_union_or_class, int (ClassType::*)>(false)) );
- VERIFY( (test_category<__is_union_or_class,
- int (ClassType::*) (int)>(false)) );
- VERIFY( (test_category<__is_union_or_class, int (int)>(false)) );
- VERIFY( (test_category<__is_union_or_class, EnumType>(false)) );
-}
-
-int main()
-{
- test01();
- return 0;
-}
diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_class/is_class.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_class/is_class.cc
new file mode 100644
index 00000000000..5e88fb5b6d5
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_class/is_class.cc
@@ -0,0 +1,61 @@
+// 2007-04-08 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2007 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 4.5.1 Primary type categories
+
+#include <tr1/type_traits>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::tr1::is_class;
+ using namespace __gnu_test;
+
+ // Positive tests.
+ VERIFY( (test_category<is_class, ClassType>(true)) );
+ VERIFY( (test_category<is_class, DerivedType>(true)) );
+ VERIFY( (test_category<is_class, ConvType>(true)) );
+ VERIFY( (test_category<is_class, AbstractClass>(true)) );
+ VERIFY( (test_category<is_class, PolymorphicClass>(true)) );
+ VERIFY( (test_category<is_class, DerivedPolymorphic>(true)) );
+
+ // Negative tests.
+ VERIFY( (test_category<is_class, UnionType>(false)) );
+ VERIFY( (test_category<is_class, void>(false)) );
+ VERIFY( (test_category<is_class, int>(false)) );
+ VERIFY( (test_category<is_class, float>(false)) );
+ VERIFY( (test_category<is_class, int[2]>(false)) );
+ VERIFY( (test_category<is_class, int*>(false)) );
+ VERIFY( (test_category<is_class, int(*)(int)>(false)) );
+ VERIFY( (test_category<is_class, float&>(false)) );
+ VERIFY( (test_category<is_class, float(&)(float)>(false)) );
+ VERIFY( (test_category<is_class, int (ClassType::*)>(false)) );
+ VERIFY( (test_category<is_class, int (ClassType::*) (int)>(false)) );
+ VERIFY( (test_category<is_class, int (int)>(false)) );
+ VERIFY( (test_category<is_class, EnumType>(false)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_class/typedefs.cc
index 65c84e03aab..8ad546ac3b6 100644
--- a/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/typedefs.cc
+++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_class/typedefs.cc
@@ -1,6 +1,6 @@
-// 2005-02-25 Paolo Carlini <pcarlini@suse.de>
+// 2007-04-08 Paolo Carlini <pcarlini@suse.de>
//
-// Copyright (C) 2005 Free Software Foundation, Inc.
+// Copyright (C) 2007 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -28,7 +28,7 @@
void test01()
{
// Check for required typedefs
- typedef std::tr1::__is_union_or_class<int> test_type;
+ typedef std::tr1::is_class<int> test_type;
typedef test_type::value_type value_type;
typedef test_type::type type;
typedef test_type::type::value_type type_value_type;
diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_union/is_union.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_union/is_union.cc
new file mode 100644
index 00000000000..e381f888b27
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_union/is_union.cc
@@ -0,0 +1,61 @@
+// 2007-04-08 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2007 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 4.5.1 Primary type categories
+
+#include <tr1/type_traits>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::tr1::is_union;
+ using namespace __gnu_test;
+
+ // Positive tests.
+ VERIFY( (test_category<is_union, UnionType>(true)) );
+
+ // Negative tests.
+ VERIFY( (test_category<is_union, ClassType>(false)) );
+ VERIFY( (test_category<is_union, DerivedType>(false)) );
+ VERIFY( (test_category<is_union, ConvType>(false)) );
+ VERIFY( (test_category<is_union, AbstractClass>(false)) );
+ VERIFY( (test_category<is_union, PolymorphicClass>(false)) );
+ VERIFY( (test_category<is_union, DerivedPolymorphic>(false)) );
+ VERIFY( (test_category<is_union, void>(false)) );
+ VERIFY( (test_category<is_union, int>(false)) );
+ VERIFY( (test_category<is_union, float>(false)) );
+ VERIFY( (test_category<is_union, int[2]>(false)) );
+ VERIFY( (test_category<is_union, int*>(false)) );
+ VERIFY( (test_category<is_union, int(*)(int)>(false)) );
+ VERIFY( (test_category<is_union, float&>(false)) );
+ VERIFY( (test_category<is_union, float(&)(float)>(false)) );
+ VERIFY( (test_category<is_union, int (ClassType::*)>(false)) );
+ VERIFY( (test_category<is_union, int (ClassType::*) (int)>(false)) );
+ VERIFY( (test_category<is_union, int (int)>(false)) );
+ VERIFY( (test_category<is_union, EnumType>(false)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_union/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_union/typedefs.cc
new file mode 100644
index 00000000000..9f24c5e9786
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_union/typedefs.cc
@@ -0,0 +1,36 @@
+// 2007-04-08 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2007 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+//
+// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES.
+
+#include <tr1/type_traits>
+
+// { dg-do compile }
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::tr1::is_union<int> test_type;
+ typedef test_type::value_type value_type;
+ typedef test_type::type type;
+ typedef test_type::type::value_type type_value_type;
+ typedef test_type::type::type type_type;
+}
diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/has_virtual_destructor/has_virtual_destructor.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/has_virtual_destructor/has_virtual_destructor.cc
new file mode 100644
index 00000000000..910aeded2d5
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/has_virtual_destructor/has_virtual_destructor.cc
@@ -0,0 +1,56 @@
+// 2007-04-08 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2007 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 4.5.3 Type properties
+
+#include <tr1/type_traits>
+#include <iostream>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::tr1::has_virtual_destructor;
+ using namespace __gnu_test;
+
+ // Positive tests.
+ VERIFY( (test_category<has_virtual_destructor,
+ VirtualDestructorClass>(true)) );
+ VERIFY( (test_category<has_virtual_destructor, std::iostream>(true)) );
+ VERIFY( (test_category<has_virtual_destructor, std::streambuf>(true)) );
+
+ // Negative tests.
+ VERIFY( (test_category<has_virtual_destructor, PolymorphicClass>(false)) );
+ VERIFY( (test_category<has_virtual_destructor, DerivedPolymorphic>(false)) );
+ VERIFY( (test_category<has_virtual_destructor, AbstractClass>(false)) );
+ VERIFY( (test_category<has_virtual_destructor, void>(false)) );
+ VERIFY( (test_category<has_virtual_destructor, int (int)>(false)) );
+ VERIFY( (test_category<has_virtual_destructor, int&>(false)) );
+ VERIFY( (test_category<has_virtual_destructor, EnumType>(false)) );
+ VERIFY( (test_category<has_virtual_destructor, ClassType>(false)) );
+ VERIFY( (test_category<has_virtual_destructor, DerivedType>(false)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/has_virtual_destructor/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/has_virtual_destructor/typedefs.cc
new file mode 100644
index 00000000000..94d81eafb21
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/has_virtual_destructor/typedefs.cc
@@ -0,0 +1,36 @@
+// 2007-04-08 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2007 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+//
+// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES.
+
+#include <tr1/type_traits>
+
+// { dg-do compile }
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::tr1::has_virtual_destructor<int> test_type;
+ typedef test_type::value_type value_type;
+ typedef test_type::type type;
+ typedef test_type::type::value_type type_value_type;
+ typedef test_type::type::type type_type;
+}
diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/is_polymorphic.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/is_polymorphic.cc
index 6a5efa046f9..6dc5c1c2c6d 100644
--- a/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/is_polymorphic.cc
+++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/is_polymorphic.cc
@@ -1,6 +1,6 @@
// 2005-03-03 Paolo Carlini <pcarlini@suse.de>
//
-// Copyright (C) 2005 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -35,6 +35,7 @@ void test01()
VERIFY( (test_category<is_polymorphic, PolymorphicClass>(true)) );
VERIFY( (test_category<is_polymorphic, DerivedPolymorphic>(true)) );
VERIFY( (test_category<is_polymorphic, AbstractClass>(true)) );
+ VERIFY( (test_category<is_polymorphic, VirtualDestructorClass>(true)) );
VERIFY( (test_category<is_polymorphic, std::iostream>(true)) );
VERIFY( (test_category<is_polymorphic, std::streambuf>(true)) );
diff --git a/libstdc++-v3/testsuite/util/testsuite_tr1.h b/libstdc++-v3/testsuite/util/testsuite_tr1.h
index b48f1a36b41..8b630bb23e9 100644
--- a/libstdc++-v3/testsuite/util/testsuite_tr1.h
+++ b/libstdc++-v3/testsuite/util/testsuite_tr1.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
// Testing utilities for the tr1 testsuite.
//
-// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -103,17 +103,20 @@ namespace __gnu_test
class AbstractClass
{
virtual void rotate(int) = 0;
- virtual ~AbstractClass();
};
class PolymorphicClass
{
virtual void rotate(int);
- virtual ~PolymorphicClass();
};
class DerivedPolymorphic : public PolymorphicClass { };
+ class VirtualDestructorClass
+ {
+ virtual ~VirtualDestructorClass();
+ };
+
union UnionType { };
class IncompleteClass;
OpenPOWER on IntegriCloud