diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-05 15:53:35 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-05 15:53:35 +0000 |
commit | aa9fc7f703dff480dc4b60f1a3f8bb430d6b55ed (patch) | |
tree | f737c1e38f42d8941932b0b3af63a2093d031a1d /libstdc++-v3/include/std | |
parent | d7ac40568605e20715c79b966ea70f1cabea4911 (diff) | |
download | gcc-aa9fc7f703dff480dc4b60f1a3f8bb430d6b55ed.tar.gz |
2010-10-05 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/type_traits (_GLIBCXX_HAS_NESTED_TYPE): Add.
* include/std/functional (_Has_result_type_helper,
_Has_result_type): Remove; use the above to define __has_result_type.
* include/bits/stl_iterator_base_types.h: Use the above to define
__has_iterator_category.
* include/bits/allocator.h (__has_allocator_type): Use the above.
* include/bits/cpp_type_traits.h (__has_iterator_category,
__is_iterator): Remove.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164993 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/std')
-rw-r--r-- | libstdc++-v3/include/std/functional | 30 | ||||
-rw-r--r-- | libstdc++-v3/include/std/type_traits | 29 |
2 files changed, 31 insertions, 28 deletions
diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index dcd7ab83d2e..f781d9e0477 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -63,33 +63,7 @@ namespace std template<typename _MemberPointer> class _Mem_fn; - /** - * Actual implementation of _Has_result_type, which uses SFINAE to - * determine if the type _Tp has a publicly-accessible member type - * result_type. - */ - template<typename _Tp> - class _Has_result_type_helper : __sfinae_types - { - template<typename _Up> - struct _Wrap_type - { }; - - template<typename _Up> - static __one __test(_Wrap_type<typename _Up::result_type>*); - - template<typename _Up> - static __two __test(...); - - public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; - }; - - template<typename _Tp> - struct _Has_result_type - : integral_constant<bool, - _Has_result_type_helper<typename remove_cv<_Tp>::type>::value> - { }; +_GLIBCXX_HAS_NESTED_TYPE(result_type) /// If we have found a result_type, extract it. template<bool _Has_result_type, typename _Functor> @@ -108,7 +82,7 @@ namespace std */ template<typename _Functor> struct _Weak_result_type_impl - : _Maybe_get_result_type<_Has_result_type<_Functor>::value, _Functor> + : _Maybe_get_result_type<__has_result_type<_Functor>::value, _Functor> { }; /// Retrieve the result type for a function type. diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index f4d0b267759..cde741eb43a 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -696,6 +696,35 @@ namespace std type; }; + /** + * Use SFINAE to determine if the type _Tp has a publicly-accessible + * member type _NTYPE. + */ +#define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \ + template<typename _Tp> \ + class __has_##_NTYPE##_helper \ + : __sfinae_types \ + { \ + template<typename _Up> \ + struct _Wrap_type \ + { }; \ + \ + template<typename _Up> \ + static __one __test(_Wrap_type<typename _Up::_NTYPE>*); \ + \ + template<typename _Up> \ + static __two __test(...); \ + \ + public: \ + static const bool value = sizeof(__test<_Tp>(0)) == 1; \ + }; \ + \ + template<typename _Tp> \ + struct __has_##_NTYPE \ + : integral_constant<bool, __has_##_NTYPE##_helper \ + <typename remove_cv<_Tp>::type>::value> \ + { }; + // @} group metaprogramming } |