Commit 6e556303 by François Dumont

Add C++11 __iterator_category_t template alias.

	* 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
parent 2c637422
2019-10-06 François Dumont <fdumont@gcc.gnu.org> 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 * include/bits/stl_algo.h (copy_n): Add __glibcxx_requires_can_increment
debug checks. debug checks.
* testsuite/25_algorithms/copy_n/debug/1_neg.cc: New. * testsuite/25_algorithms/copy_n/debug/1_neg.cc: New.
......
...@@ -208,11 +208,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -208,11 +208,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
//@} //@}
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
template<typename _Iter>
using __iterator_category_t
= typename iterator_traits<_Iter>::iterator_category;
template<typename _InIter> template<typename _InIter>
using _RequireInputIter = typename using _RequireInputIter =
enable_if<is_convertible<typename __enable_if_t<is_convertible<__iterator_category_t<_InIter>,
iterator_traits<_InIter>::iterator_category, input_iterator_tag>::value>;
input_iterator_tag>::value>::type;
#endif #endif
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
......
...@@ -230,8 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -230,8 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// @{ /// @{
/// @cond undocumented /// @cond undocumented
template<typename _It, typename _Traits = iterator_traits<_It>, template<typename _It, typename _Cat = __iterator_category_t<_It>>
typename _Cat = typename _Traits::iterator_category>
using __is_random_access_iter using __is_random_access_iter
= is_base_of<random_access_iterator_tag, _Cat>; = is_base_of<random_access_iterator_tag, _Cat>;
/// @endcond /// @endcond
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment