Add C++11 __iterator_category_t template alias.
authorFrançois Dumont <fdumont@gcc.gnu.org>
Sun, 6 Oct 2019 15:10:40 +0000 (15:10 +0000)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Sun, 6 Oct 2019 15:10:40 +0000 (15:10 +0000)
* include/bits/stl_iterator_base_types.h (__iterator_category_t): Define
for C++11.
(_RequireInputIte): Likewise and use __enable_if_t.
* include/std/numeric
(__is_random_access_iter): Use __iterator_category_t.

From-SVN: r276637

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_iterator_base_types.h
libstdc++-v3/include/std/numeric

index 5cb2e2924eefbaa5db60e474a69f068798fd076f..40d9081a3c80810ffae72db2514ac8f4dfaaac31 100644 (file)
@@ -1,5 +1,11 @@
 2019-10-06  François Dumont  <fdumont@gcc.gnu.org>
 
+       * include/bits/stl_iterator_base_types.h (__iterator_category_t): Define
+       for C++11.
+       (_RequireInputIte): Likewise and use __enable_if_t.
+       * include/std/numeric
+       (__is_random_access_iter): Use __iterator_category_t.
+
        * include/bits/stl_algo.h (copy_n): Add __glibcxx_requires_can_increment
        debug checks.
        * testsuite/25_algorithms/copy_n/debug/1_neg.cc: New.
index af69dbb017a9c6e7bd339908f0274f9626d97812..951e704e468bba5214ff61e28109275b5e85dd0a 100644 (file)
@@ -208,11 +208,14 @@ _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>;
 #endif
 
 _GLIBCXX_END_NAMESPACE_VERSION
index 239276946b5e8617d701df9804f249c7dba4e190..a164a9e6430faf571f1af51cc1e21db5e1b93a20 100644 (file)
@@ -230,8 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// @{
 
   /// @cond undocumented
-  template<typename _It, typename _Traits = iterator_traits<_It>,
-          typename _Cat = typename _Traits::iterator_category>
+  template<typename _It, typename _Cat = __iterator_category_t<_It>>
     using __is_random_access_iter
       = is_base_of<random_access_iterator_tag, _Cat>;
   /// @endcond