From 77633f4cd05047cd8b46887e4708086deb58cd7c Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Fri, 11 Nov 2005 20:10:20 +0000 Subject: [PATCH] re PR libstdc++/24799 (std::tr1::hash missing inheritance) 2005-11-11 Paolo Carlini 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 | 17 +++++ libstdc++-v3/include/tr1/boost_shared_ptr.h | 36 +++------ libstdc++-v3/include/tr1/functional | 9 ++- libstdc++-v3/include/tr1/type_traits | 2 +- .../memory/shared_ptr/modifiers/24805.cc | 30 ++++++++ .../type_properties/is_polymorphic/24809.cc | 27 +++++++ .../tr1/6_containers/unordered/hash/24799.cc | 74 +++++++++++++++++++ 7 files changed, 169 insertions(+), 26 deletions(-) create mode 100644 libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/24805.cc create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/24809.cc create mode 100644 libstdc++-v3/testsuite/tr1/6_containers/unordered/hash/24799.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1e03518357e..7e7f137a474 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,20 @@ +2005-11-11 Paolo Carlini + + 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 * testsuite/tr1/2_general_utilities/memory/ diff --git a/libstdc++-v3/include/tr1/boost_shared_ptr.h b/libstdc++-v3/include/tr1/boost_shared_ptr.h index 2c3e27ca537..ec940a9c25f 100644 --- a/libstdc++-v3/include/tr1/boost_shared_ptr.h +++ b/libstdc++-v3/include/tr1/boost_shared_ptr.h @@ -705,8 +705,13 @@ template shared_count _M_refcount; // reference counter }; // shared_ptr -// 2.2.3.9 shared_ptr casts +// 2.2.3.8 shared_ptr specialized algorithms. +template + 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 * shared_ptr(static_cast(r.get())) * will eventually result in undefined behaviour, @@ -902,6 +907,12 @@ template }; // weak_ptr +// 2.2.4.7 weak_ptr specialized algorithms. +template + void + swap(weak_ptr<_Tp>& __a, weak_ptr<_Tp>& __b) + { __a.swap(__b); } + template class enable_shared_from_this @@ -957,29 +968,6 @@ template }; } // namespace tr1 - -/** - * @brief std::swap() specialisation for shared_ptr. - * @relates shared_ptr. - */ -template - 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 - void - swap(tr1::weak_ptr<_Tp>& __a, tr1::weak_ptr<_Tp>& __b) - { - __a.swap(__b); - } - } // namespace std #endif diff --git a/libstdc++-v3/include/tr1/functional b/libstdc++-v3/include/tr1/functional index 905e6cbfb25..9672da8fe7c 100644 --- a/libstdc++-v3/include/tr1/functional +++ b/libstdc++-v3/include/tr1/functional @@ -1103,6 +1103,7 @@ namespace tr1 #define tr1_hashtable_define_trivial_hash(T) \ template<> \ struct hash \ + : public std::unary_function \ { \ std::size_t \ operator()(T val) const \ @@ -1125,6 +1126,7 @@ namespace tr1 template struct hash + : public std::unary_function { 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 - { + : public std::unary_function + { 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 + : public std::unary_function { std::size_t operator()(const std::wstring& s) const @@ -1206,6 +1210,7 @@ namespace tr1 template<> struct hash + : public std::unary_function { std::size_t operator()(float fval) const @@ -1222,6 +1227,7 @@ namespace tr1 template<> struct hash + : public std::unary_function { std::size_t operator()(double dval) const @@ -1240,6 +1246,7 @@ namespace tr1 // 10 bytes -> 12 bytes) and resort to frexp. template<> struct hash + : public std::unary_function { std::size_t operator()(long double ldval) const diff --git a/libstdc++-v3/include/tr1/type_traits b/libstdc++-v3/include/tr1/type_traits index 4ef864da415..c89bb8eae78 100644 --- a/libstdc++-v3/include/tr1/type_traits +++ b/libstdc++-v3/include/tr1/type_traits @@ -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 index 00000000000..94824f6167d --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/memory/shared_ptr/modifiers/24805.cc @@ -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 + +// 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 index 00000000000..0b8ab0f7167 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/24809.cc @@ -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 +#include + +// libstdc++/24809 +static const bool b = std::tr1::is_polymorphic::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 index 00000000000..90a336bdf2e --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered/hash/24799.cc @@ -0,0 +1,74 @@ +// 2005-11-11 Paolo Carlini +// +// 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 +#include +#include +#include +#include + +template + void + do_test() + { + bool test __attribute__((unused)) = true; + + using std::tr1::is_same; + using __gnu_test::test_relationship; + + typedef typename std::tr1::hash::argument_type argument_type; + typedef typename std::tr1::hash::result_type result_type; + + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + } + +// libstdc++/24799 +void test01() +{ + do_test(); + do_test(); + do_test(); + do_test(); + do_test(); + do_test(); + do_test(); + do_test(); + do_test(); + do_test(); + do_test(); + do_test(); + do_test(); + do_test(); + do_test(); + +#ifdef _GLIBCXX_USE_WCHAR_T + do_test(); + do_test(); +#endif +} + +int main() +{ + test01(); + return 0; +}