re PR libstdc++/24799 (std::tr1::hash missing inheritance)

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
This commit is contained in:
Paolo Carlini 2005-11-11 20:10:20 +00:00 committed by Paolo Carlini
parent a7f4ccb197
commit 77633f4cd0
7 changed files with 169 additions and 26 deletions

View 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/

View 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

View 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

View file

@ -321,7 +321,7 @@ namespace tr1
: public _Up
{
virtual void __dummy();
virtual ~__second();
virtual ~__second() throw();
};
public:

View file

@ -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;

View file

@ -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;

View file

@ -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;
}