This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add std::__iterator_category_t


Hi

    May I add this convenient function ? I'll also use it in coming patches.

    Note that I removed a template parameter in __is_random_access_iter in C++11.


    * include/bits/stl_iterator_base_types.h (__iterator_category_t): Define
    for C++11.
    (__is_random_access_iter): Adapt to use latter.
    (_RequireInputIte): Likewise and use __enable_if_t.

    Tested under Linux x86_64.

François

diff --git a/libstdc++-v3/include/bits/stl_iterator_base_types.h b/libstdc++-v3/include/bits/stl_iterator_base_types.h
index 8135f4857fc..d12ac3a20ea 100644
--- a/libstdc++-v3/include/bits/stl_iterator_base_types.h
+++ b/libstdc++-v3/include/bits/stl_iterator_base_types.h
@@ -208,14 +208,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   //@}
 
 #if __cplusplus >= 201103L
+  template<typename _Iter>
+    using __iterator_category_t
+      = typename iterator_traits<_Iter>::iterator_category;
+
   template<typename _InIter>
-    using _RequireInputIter = typename
-      enable_if<is_convertible<typename
-		iterator_traits<_InIter>::iterator_category,
-			       input_iterator_tag>::value>::type;
+    using _RequireInputIter =
+      __enable_if_t<is_convertible<__iterator_category_t<_InIter>,
+				   input_iterator_tag>::value>;
 
-  template<typename _It, typename _Traits = iterator_traits<_It>,
-	   typename _Cat = typename _Traits::iterator_category>
+  template<typename _It, typename _Cat = __iterator_category_t<_It>>
     struct __is_random_access_iter
       : is_base_of<random_access_iterator_tag, _Cat>
     {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]