re PR libstdc++/24799 (std::tr1::hash missing inheritance)
authorPaolo Carlini <pcarlini@suse.de>
Fri, 11 Nov 2005 20:10:20 +0000 (20:10 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 11 Nov 2005 20:10:20 +0000 (20:10 +0000)
2005-11-11  Paolo Carlini  <pcarlini@suse.de>

PR libstdc++/24799
* include/tr1/functional (hash): Inherit from std::unary_function.
* testsuite/tr1/6_containers/unordered/hash/24799.cc: New.

PR libstdc++/24805
* include/tr1/boost_shared_ptr.h (swap(shared_ptr<>&, shared_ptr<>&),
swap(weak_ptr<>&, weak_ptr<>&)): Move inside namespace tr1.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/
24805.cc: New.

PR libstdc++/24809
* include/tr1/type_traits (__is_polymorhpic_helper): Adjust destructor.
* testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/
24809.cc: New.

From-SVN: r106796

libstdc++-v3/ChangeLog
libstdc++-v3/include/tr1/boost_shared_ptr.h
libstdc++-v3/include/tr1/functional
libstdc++-v3/include/tr1/type_traits
libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/24805.cc [new file with mode: 0644]
libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/24809.cc [new file with mode: 0644]
libstdc++-v3/testsuite/tr1/6_containers/unordered/hash/24799.cc [new file with mode: 0644]

index 1e03518..7e7f137 100644 (file)
@@ -1,3 +1,20 @@
+2005-11-11  Paolo Carlini  <pcarlini@suse.de>
+
+       PR libstdc++/24799
+       * include/tr1/functional (hash): Inherit from std::unary_function.
+       * testsuite/tr1/6_containers/unordered/hash/24799.cc: New.
+
+       PR libstdc++/24805
+       * include/tr1/boost_shared_ptr.h (swap(shared_ptr<>&, shared_ptr<>&),
+       swap(weak_ptr<>&, weak_ptr<>&)): Move inside namespace tr1.
+       * testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/
+       24805.cc: New.
+
+       PR libstdc++/24809
+       * include/tr1/type_traits (__is_polymorhpic_helper): Adjust destructor.
+       * testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/
+       24809.cc: New.
+
 2005-11-10  Paolo Carlini  <pcarlini@suse.de>
 
        * testsuite/tr1/2_general_utilities/memory/
index 2c3e27c..ec940a9 100644 (file)
@@ -705,8 +705,13 @@ template<typename _Tp>
     shared_count _M_refcount;    // reference counter
   };  // shared_ptr
 
-// 2.2.3.9 shared_ptr casts
+// 2.2.3.8 shared_ptr specialized algorithms.
+template<typename _Tp>
+  inline void
+  swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b)
+  { __a.swap(__b); }
 
+// 2.2.3.9 shared_ptr casts
 /** @warning The seemingly equivalent
  *           <code>shared_ptr<T>(static_cast<T*>(r.get()))</code>
  *           will eventually result in undefined behaviour,
@@ -902,6 +907,12 @@ template<typename _Tp>
 
   };  // weak_ptr
 
+// 2.2.4.7 weak_ptr specialized algorithms.
+template<typename _Tp>
+  void
+  swap(weak_ptr<_Tp>& __a, weak_ptr<_Tp>& __b)
+  { __a.swap(__b); }
+
 
 template<typename _Tp>
   class enable_shared_from_this
@@ -957,29 +968,6 @@ template<typename _Tp>
   };
 
 } // namespace tr1
-
-/**
- *  @brief   std::swap() specialisation for shared_ptr.
- *  @relates shared_ptr.
- */
-template<typename _Tp>
-  inline void
-  swap(tr1::shared_ptr<_Tp>& __a, tr1::shared_ptr<_Tp>& __b)
-  {
-    __a.swap(__b);
-  }
-
-/**
- *  @brief   std::swap() specialisation for weak_ptr.
- *  @relates weak_ptr.
- */
-template<typename _Tp>
-  void
-  swap(tr1::weak_ptr<_Tp>& __a, tr1::weak_ptr<_Tp>& __b)
-  {
-    __a.swap(__b);
-  }
-
 } // namespace std
 
 #endif
index 905e6cb..9672da8 100644 (file)
@@ -1103,6 +1103,7 @@ namespace tr1
 #define tr1_hashtable_define_trivial_hash(T)            \
   template<>                                            \
     struct hash<T>                                      \
+    : public std::unary_function<T, std::size_t>        \
     {                                                   \
       std::size_t                                       \
       operator()(T val) const                           \
@@ -1125,6 +1126,7 @@ namespace tr1
 
   template<typename T>
     struct hash<T*>
+    : public std::unary_function<T*, std::size_t>
     {
       std::size_t
       operator()(T* p) const
@@ -1185,7 +1187,8 @@ namespace tr1
   // for TR1 .cc files, these should go in one.
   template<>
     struct hash<std::string>
-    {
+    : public std::unary_function<std::string, std::size_t>
+    {      
       std::size_t
       operator()(const std::string& s) const
       { return Fnv_hash<>::hash(s.data(), s.length()); }
@@ -1194,6 +1197,7 @@ namespace tr1
 #ifdef _GLIBCXX_USE_WCHAR_T
   template<>
     struct hash<std::wstring>
+    : public std::unary_function<std::wstring, std::size_t>
     {
       std::size_t
       operator()(const std::wstring& s) const
@@ -1206,6 +1210,7 @@ namespace tr1
 
   template<>
     struct hash<float>
+    : public std::unary_function<float, std::size_t>
     {
       std::size_t
       operator()(float fval) const
@@ -1222,6 +1227,7 @@ namespace tr1
 
   template<>
     struct hash<double>
+    : public std::unary_function<double, std::size_t>
     {
       std::size_t
       operator()(double dval) const
@@ -1240,6 +1246,7 @@ namespace tr1
   // 10 bytes -> 12 bytes) and resort to frexp.
   template<>
     struct hash<long double>
+    : public std::unary_function<long double, std::size_t>
     {
       std::size_t
       operator()(long double ldval) const
index 4ef864d..c89bb8e 100644 (file)
@@ -321,7 +321,7 @@ namespace tr1
         : public _Up
        { 
          virtual void __dummy();
-         virtual ~__second();
+         virtual ~__second() throw();
        };
 
     public:
diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/24805.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/24805.cc
new file mode 100644 (file)
index 0000000..94824f6
--- /dev/null
@@ -0,0 +1,30 @@
+// { dg-do compile }
+
+// Copyright (C) 2005 Free Software Foundation
+//
+// 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.
+
+// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
+
+#include <tr1/memory>
+
+// 2.2.3.4 shared_ptr modifiers [tr.util.smartptr.shared.mod]
+
+// swap
+
+// libstdc++/24805
+using std::tr1::swap;
diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/24809.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/24809.cc
new file mode 100644 (file)
index 0000000..0b8ab0f
--- /dev/null
@@ -0,0 +1,27 @@
+// { dg-do compile }
+
+// 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.3 Type properties
+
+#include <tr1/type_traits>
+#include <exception>
+
+// libstdc++/24809
+static const bool b = std::tr1::is_polymorphic<std::exception>::value;
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered/hash/24799.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered/hash/24799.cc
new file mode 100644 (file)
index 0000000..90a336b
--- /dev/null
@@ -0,0 +1,74 @@
+// 2005-11-11  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.
+
+// 6.3.3 Class template hash
+
+#include <tr1/functional>
+#include <string>
+#include <tr1/type_traits>
+#include <testsuite_tr1.h>
+#include <testsuite_hooks.h>
+
+template<typename T>
+  void
+  do_test()
+  {
+    bool test __attribute__((unused)) = true;
+
+    using std::tr1::is_same;
+    using __gnu_test::test_relationship;
+    
+    typedef typename std::tr1::hash<T>::argument_type  argument_type;
+    typedef typename std::tr1::hash<T>::result_type    result_type;
+    
+    VERIFY( (test_relationship<is_same, argument_type, T>(true)) );
+    VERIFY( (test_relationship<is_same, result_type, std::size_t>(true)) );
+  }
+  
+// libstdc++/24799
+void test01()
+{
+  do_test<bool>();
+  do_test<char>();
+  do_test<signed char>();
+  do_test<unsigned char>();
+  do_test<short>();
+  do_test<int>();
+  do_test<long>();
+  do_test<unsigned short>();
+  do_test<unsigned int>();
+  do_test<unsigned long>();
+  do_test<int*>();
+  do_test<std::string>();
+  do_test<float>();
+  do_test<double>();
+  do_test<long double>();
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+  do_test<wchar_t>();
+  do_test<std::wstring>();
+#endif
+}
+
+int main()
+{
+  test01();
+  return 0;
+}