From e1c444fef05475d8f7b4fa2f746ad49ba78b0b69 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Dumont?= Date: Thu, 30 Apr 2015 11:36:52 +0000 Subject: [PATCH] =?utf8?q?2015-04-30=20=20Fran=C3=A7ois=20Dumont=20=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * include/bits/cpp_type_traits.h (__gnu_cxx::__is_normal_iterator): Delete. * include/bits/stl_algobase.h (std::__niter_base): Adapt. * include/bits/stl_iterator.h (__make_reverse_iterator): New in C++11. (std::__niter_base): Overloads for std::reverse_iterator, __gnu_cxx::__normal_iterator and std::move_iterator. From-SVN: r222617 --- libstdc++-v3/ChangeLog | 9 +++++ libstdc++-v3/include/bits/cpp_type_traits.h | 29 ---------------- libstdc++-v3/include/bits/stl_algobase.h | 16 ++++----- libstdc++-v3/include/bits/stl_iterator.h | 38 +++++++++++++++++++-- 4 files changed, 51 insertions(+), 41 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 02b07ac0a9e..53661dfa9bd 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2015-04-30 François Dumont + + * include/bits/cpp_type_traits.h + (__gnu_cxx::__is_normal_iterator): Delete. + * include/bits/stl_algobase.h (std::__niter_base): Adapt. + * include/bits/stl_iterator.h (__make_reverse_iterator): New in C++11. + (std::__niter_base): Overloads for std::reverse_iterator, + __gnu_cxx::__normal_iterator and std::move_iterator. + 2015-04-30 François Dumont * include/bits/hashtable_policy.h (_Prime_rehash_policy::_S_n_primes): diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h index 8c6bb7f2cfa..21429175c05 100644 --- a/libstdc++-v3/include/bits/cpp_type_traits.h +++ b/libstdc++-v3/include/bits/cpp_type_traits.h @@ -64,17 +64,6 @@ // removed. // -// Forward declaration hack, should really include this from somewhere. -namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) -{ -_GLIBCXX_BEGIN_NAMESPACE_VERSION - - template - class __normal_iterator; - -_GLIBCXX_END_NAMESPACE_VERSION -} // namespace - namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -330,24 +319,6 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) typedef __true_type __type; }; - // - // Normal iterator type - // - template - struct __is_normal_iterator - { - enum { __value = 0 }; - typedef __false_type __type; - }; - - template - struct __is_normal_iterator< __gnu_cxx::__normal_iterator<_Iterator, - _Container> > - { - enum { __value = 1 }; - typedef __true_type __type; - }; - // // An arithmetic type is an integer type or a floating point type // diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index c82d96d25bb..630b3a04fc2 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -270,19 +270,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __a; } - // If _Iterator is a __normal_iterator return its base (a plain pointer, - // normally) otherwise return it untouched. See copy, fill, ... + // Fallback implementation of the function in bits/stl_iterator.h used to + // remove the __normal_iterator wrapper. See copy, fill, ... template - struct _Niter_base - : _Iter_base<_Iterator, __is_normal_iterator<_Iterator>::__value> - { }; - - template - inline typename _Niter_base<_Iterator>::iterator_type + inline _Iterator __niter_base(_Iterator __it) - { return std::_Niter_base<_Iterator>::_S_base(__it); } + { return __it; } - // Likewise, for move_iterator. + // If _Iterator is a move_iterator return its base otherwise return it + // untouched. See copy, fill, ... template struct _Miter_base : _Iter_base<_Iterator, __is_move_iterator<_Iterator>::__value> diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index 7b5872ee0e0..d4ea6577a49 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -388,8 +388,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __y.base() - __x.base(); } //@} -#if __cplusplus > 201103L -#define __cpp_lib_make_reverse_iterator 201402 +#if __cplusplus >= 201103L + // Same as C++14 make_reverse_iterator but used in C++03 mode too. + template + inline reverse_iterator<_Iterator> + __make_reverse_iterator(_Iterator __i) + { return reverse_iterator<_Iterator>(__i); } + +# if __cplusplus > 201103L +# define __cpp_lib_make_reverse_iterator 201402 // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 2285. make_reverse_iterator @@ -398,6 +405,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline reverse_iterator<_Iterator> make_reverse_iterator(_Iterator __i) { return reverse_iterator<_Iterator>(__i); } +# endif +#endif + +#if __cplusplus >= 201103L + template + auto + __niter_base(reverse_iterator<_Iterator> __it) + -> decltype(__make_reverse_iterator(__niter_base(__it.base()))) + { return __make_reverse_iterator(__niter_base(__it.base())); } #endif // 24.4.2.2.1 back_insert_iterator @@ -935,6 +951,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } // namespace +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + _Iterator + __niter_base(__gnu_cxx::__normal_iterator<_Iterator, _Container> __it) + { return __it.base(); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + #if __cplusplus >= 201103L namespace std _GLIBCXX_VISIBILITY(default) @@ -1168,6 +1196,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // @} group iterators + template + auto + __niter_base(move_iterator<_Iterator> __it) + -> decltype(make_move_iterator(__niter_base(__it.base()))) + { return make_move_iterator(__niter_base(__it.base())); } + _GLIBCXX_END_NAMESPACE_VERSION } // namespace -- 2.30.2