diff options
author | Paolo Carlini <pcarlini@suse.de> | 2007-04-10 15:12:54 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2007-04-10 15:12:54 +0000 |
commit | 05beb8e72054de470b0dc011f65c6f27852a4e0c (patch) | |
tree | beda0edb41949bb0cc80e97d569db8ac5b50b969 | |
parent | 0218c0120c16cb1e52d240737adf1ff9c45c6f52 (diff) | |
download | gcc-05beb8e72054de470b0dc011f65c6f27852a4e0c.zip gcc-05beb8e72054de470b0dc011f65c6f27852a4e0c.tar.gz gcc-05beb8e72054de470b0dc011f65c6f27852a4e0c.tar.bz2 |
type_traits (__is_function_helper): New, uses variadic templates.
2007-04-10 Paolo Carlini <pcarlini@suse.de>
* include/tr1/type_traits (__is_function_helper): New, uses
variadic templates.
(is_function): Forward to the latter.
* testsuite/tr1/4_metaprogramming/primary_type_categories/
is_function/is_function.cc: Add test.
From-SVN: r123695
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1/type_traits | 22 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_function/is_function.cc | 3 |
3 files changed, 26 insertions, 7 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 410f4fc..c752c22 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,13 @@ 2007-04-10 Paolo Carlini <pcarlini@suse.de> + * include/tr1/type_traits (__is_function_helper): New, uses + variadic templates. + (is_function): Forward to the latter. + * testsuite/tr1/4_metaprogramming/primary_type_categories/ + is_function/is_function.cc: Add test. + +2007-04-10 Paolo Carlini <pcarlini@suse.de> + PR libstdc++/28277 (partial: vstring bits) * include/bits/ostream_insert.h: New. * include/Makefile.am: Add. diff --git a/libstdc++-v3/include/tr1/type_traits b/libstdc++-v3/include/tr1/type_traits index c29701c..8645427 100644 --- a/libstdc++-v3/include/tr1/type_traits +++ b/libstdc++-v3/include/tr1/type_traits @@ -34,6 +34,8 @@ #ifndef _TR1_TYPE_TRAITS #define _TR1_TYPE_TRAITS 1 +#pragma GCC system_header + #include <bits/c++config.h> #include <tr1/type_traits_fwd.h> @@ -171,14 +173,22 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_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 is_function - : public integral_constant<bool, !(is_void<_Tp>::value - || is_scalar<_Tp>::value - || is_array<_Tp>::value - || is_reference<_Tp>::value - || is_union<_Tp>::value - || is_class<_Tp>::value)> + : public integral_constant<bool, (__is_function_helper<typename + remove_cv<_Tp>::type>::value)> { }; /// @brief composite type traits [4.5.2]. diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_function/is_function.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_function/is_function.cc index a1e2317..1ada9120 100644 --- a/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_function/is_function.cc +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_function/is_function.cc @@ -1,6 +1,6 @@ // 2004-12-16 Paolo Carlini <pcarlini@suse.de> // -// Copyright (C) 2004, 2005 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 @@ -34,6 +34,7 @@ void test01() VERIFY( (test_category<is_function, int (int)>(true)) ); VERIFY( (test_category<is_function, ClassType (ClassType)>(true)) ); VERIFY( (test_category<is_function, float (int, float, int[], int&)>(true)) ); + VERIFY( (test_category<is_function, int (int, ...)>(true)) ); // Negative tests. VERIFY( (test_category<is_function, int&>(false)) ); |