type_traits_fwd.h (__is_union_or_class): Remove.
authorPaolo Carlini <pcarlini@suse.de>
Mon, 9 Apr 2007 17:07:37 +0000 (17:07 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 9 Apr 2007 17:07:37 +0000 (17:07 +0000)
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.

From-SVN: r123675

13 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/tr1/type_traits
libstdc++-v3/include/tr1/type_traits_fwd.h
libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/is_union_or_class.cc [deleted file]
libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/typedefs.cc [deleted file]
libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_class/is_class.cc [new file with mode: 0644]
libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_class/typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_union/is_union.cc [new file with mode: 0644]
libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_union/typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/has_virtual_destructor/has_virtual_destructor.cc [new file with mode: 0644]
libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/has_virtual_destructor/typedefs.cc [new file with mode: 0644]
libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/is_polymorphic.cc
libstdc++-v3/testsuite/util/testsuite_tr1.h

index 8785968d9fbecf551abf1bad0ed306348c9b6dd7..f180ad7c4b4df96911bbe9f71829a29fd476f3d6 100644 (file)
@@ -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
index 996ecf6fd93c5711a1fadb6607a113ec8dda6695..c29701c8de0baa9fbc54552d75adb48828fa1ce4 100644 (file)
@@ -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,
index 6f8e71a0c32471f8e74609abf557714c5c88fc63..c6e80a3a4b982ae8a8aaa4e1fbf4aaeec6389c87 100644 (file)
@@ -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 (file)
index 82c727d..0000000
+++ /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/composite_type_traits/is_union_or_class/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/typedefs.cc
deleted file mode 100644 (file)
index 65c84e0..0000000
+++ /dev/null
@@ -1,36 +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.
-
-// 
-// 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_or_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;
-  typedef test_type::type::type               type_type;
-}
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 (file)
index 0000000..5e88fb5
--- /dev/null
@@ -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/primary_type_categories/is_class/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_class/typedefs.cc
new file mode 100644 (file)
index 0000000..8ad546a
--- /dev/null
@@ -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_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;
+  typedef test_type::type::type               type_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 (file)
index 0000000..e381f88
--- /dev/null
@@ -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 (file)
index 0000000..9f24c5e
--- /dev/null
@@ -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 (file)
index 0000000..910aede
--- /dev/null
@@ -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 (file)
index 0000000..94d81ea
--- /dev/null
@@ -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;
+}
index 6a5efa046f97b4e643508207949fa889b06cda28..6dc5c1c2c6d098fd8927882aa1df150a3693543d 100644 (file)
@@ -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)) );
 
index b48f1a36b4118ddd4df9120e6af22de674cb66de..8b630bb23e9056b071f531a0c9b82a5bb0460e54 100644 (file)
@@ -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;