diff options
author | Paolo Carlini <paolo@gcc.gnu.org> | 2008-03-20 20:28:54 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2008-03-20 20:28:54 +0000 |
commit | 33c8c0b69ca7153f669c2dc5e6b0a06f350c1b70 (patch) | |
tree | 21c08e41ed1b3c815c35b381105a9f66bc9d9150 | |
parent | 433d52fd4367adf92c7ecda8c1784a7ba51096a5 (diff) | |
download | gcc-33c8c0b69ca7153f669c2dc5e6b0a06f350c1b70.zip gcc-33c8c0b69ca7153f669c2dc5e6b0a06f350c1b70.tar.gz gcc-33c8c0b69ca7153f669c2dc5e6b0a06f350c1b70.tar.bz2 |
re PR libstdc++/35637 (tr1::function fails with const member function pointer)
2008-03-20 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/35637
* include/tr1_impl/type_traits (struct __in_array): Add back.
(is_function): Use it.
* testsuite/tr1/4_metaprogramming/is_function/35637.cc: New.
From-SVN: r133395
-rw-r--r-- | libstdc++-v3/ChangeLog | 10 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1_impl/type_traits | 34 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/tr1/4_metaprogramming/is_function/35637.cc | 35 |
3 files changed, 62 insertions, 17 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 394fea7..578a36c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,7 +1,13 @@ +2008-03-20 Paolo Carlini <pcarlini@suse.de> + + PR libstdc++/35637 + * include/tr1_impl/type_traits (struct __in_array): Add back. + (is_function): Use it. + * testsuite/tr1/4_metaprogramming/is_function/35637.cc: New. + 2008-03-20 Johannes Singler <singler@ira.uka.de> - * include/parallel/set_operations.h: Removed superfluous - set_intersection. + * include/parallel/set_operations.h (set_intersection): Remove. 2008-03-19 Benjamin Kosnik <bkoz@redhat.com> diff --git a/libstdc++-v3/include/tr1_impl/type_traits b/libstdc++-v3/include/tr1_impl/type_traits index 2a6227b..9298aae 100644 --- a/libstdc++-v3/include/tr1_impl/type_traits +++ b/libstdc++-v3/include/tr1_impl/type_traits @@ -1,6 +1,6 @@ // TR1 type_traits -*- C++ -*- -// Copyright (C) 2007 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008 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 @@ -163,25 +163,29 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 : public integral_constant<bool, __is_class(_Tp)> { }; - template<typename> - struct __is_function_helper - : public false_type { }; - - template<typename _Res, typename... _ArgTypes> - struct __is_function_helper<_Res(_ArgTypes...)> - : public true_type { }; - - template<typename _Res, typename... _ArgTypes> - struct __is_function_helper<_Res(_ArgTypes......)> - : public true_type { }; + 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; + }; template<typename _Tp> - struct remove_cv; + struct is_abstract; template<typename _Tp> struct is_function - : public integral_constant<bool, (__is_function_helper<typename - remove_cv<_Tp>::type>::value)> + : public integral_constant<bool, !(__in_array<_Tp>::__value + || is_abstract<_Tp>::value + || is_reference<_Tp>::value + || is_void<_Tp>::value)> { }; /// @brief composite type traits [4.5.2]. diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/is_function/35637.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/is_function/35637.cc new file mode 100644 index 0000000..0c52436 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/is_function/35637.cc @@ -0,0 +1,35 @@ +// { dg-options "-pedantic-errors" } +// { dg-do compile } + +// Copyright (C) 2008 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/functional> + +struct S +{ + void F() const {} +}; + +// libstdc++/35637 +void test01() +{ + std::tr1::function<void (S *)> a(&S::F); +} |