diff options
author | Paolo Carlini <pcarlini@suse.de> | 2004-07-02 14:49:09 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2004-07-02 14:49:09 +0000 |
commit | 5e91e92ede69d69e331a6acac2502a69e4a5abb6 (patch) | |
tree | ef4bfafe4c9e720ecea1bb370055ac81c0f2892a | |
parent | ec13a3ef9b7ebf476a9f27276afba8b27dfbcf2c (diff) | |
download | gcc-5e91e92ede69d69e331a6acac2502a69e4a5abb6.zip gcc-5e91e92ede69d69e331a6acac2502a69e4a5abb6.tar.gz gcc-5e91e92ede69d69e331a6acac2502a69e4a5abb6.tar.bz2 |
type_traits.h (_Is_normal_iterator): Move...
2004-07-02 Paolo Carlini <pcarlini@suse.de>
* include/bits/type_traits.h (_Is_normal_iterator): Move...
* include/bits/cpp_type_traits.h: ... here, renamed to
__is_normal_iterator and consistent with the other traits.
* include/bits/stl_algobase.h (__copy_ni1, __copy_ni2): Convert
to the struct __copy_normal and three specializations.
(__copy_backward_output_normal_iterator,
__copy_backward_input_normal_iterator): Likewise, convert to
the struct __copy_backward_normal and three specializations.
(copy, copy_backward): Use the latter.
(__copy_aux, __copy_backward_aux): Very minor tweaks.
From-SVN: r84019
-rw-r--r-- | libstdc++-v3/ChangeLog | 13 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/cpp_type_traits.h | 31 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_algobase.h | 138 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/type_traits.h | 20 |
4 files changed, 118 insertions, 84 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f981c0f..4a28639 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,16 @@ +2004-07-02 Paolo Carlini <pcarlini@suse.de> + + * include/bits/type_traits.h (_Is_normal_iterator): Move... + * include/bits/cpp_type_traits.h: ... here, renamed to + __is_normal_iterator and consistent with the other traits. + * include/bits/stl_algobase.h (__copy_ni1, __copy_ni2): Convert + to the struct __copy_normal and three specializations. + (__copy_backward_output_normal_iterator, + __copy_backward_input_normal_iterator): Likewise, convert to + the struct __copy_backward_normal and three specializations. + (copy, copy_backward): Use the latter. + (__copy_aux, __copy_backward_aux): Very minor tweaks. + 2004-07-01 Paolo Carlini <pcarlini@suse.de> * include/bits/stl_algobase.h (__copy_trivial): Remove. diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h index bf9254f..feb7b1c 100644 --- a/libstdc++-v3/include/bits/cpp_type_traits.h +++ b/libstdc++-v3/include/bits/cpp_type_traits.h @@ -42,7 +42,7 @@ // // This file provides some compile-time information about various types. // These representations were designed, on purpose, to be constant-expressions -// and not types as found in <stl/bits/type_traits.h>. In particular, they +// and not types as found in <bits/type_traits.h>. In particular, they // can be used in control structures and the optimizer hopefully will do // the obvious thing. // @@ -77,6 +77,13 @@ namespace __gnu_internal __two& __test_type (...); } // namespace __gnu_internal +// Forward declaration hack, should really include this from somewhere. +namespace __gnu_cxx +{ + template<typename _Iterator, typename _Container> + class __normal_iterator; +} // namespace __gnu_cxx + namespace std { // Compare for equality of types. @@ -325,6 +332,28 @@ namespace std }; // + // Normal iterator type + // + template<typename _Tp> + struct __is_normal_iterator + { + enum + { + _M_type = 0 + }; + }; + + template<typename _Iterator, typename _Container> + struct __is_normal_iterator< __gnu_cxx::__normal_iterator<_Iterator, + _Container> > + { + enum + { + _M_type = 1 + }; + }; + + // // An arithmetic type is an integer type or a floating point type // template<typename _Tp> diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 1b441e0..39a52ca 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -66,10 +66,8 @@ #include <climits> #include <cstdlib> #include <cstddef> -#include <new> #include <iosfwd> #include <bits/stl_pair.h> -#include <bits/type_traits.h> #include <bits/cpp_type_traits.h> #include <bits/stl_iterator_base_types.h> #include <bits/stl_iterator_base_funcs.h> @@ -220,7 +218,7 @@ namespace std return __a; } - // All of these auxiliary functions serve two purposes. (1) Replace + // All of these auxiliary structs serve two purposes. (1) Replace // calls to copy with memmove whenever possible. (Memmove, not memcpy, // because the input and output ranges are permitted to overlap.) // (2) If we're using random access iterators, then write the loop as @@ -276,7 +274,7 @@ namespace std typedef typename iterator_traits<_II>::value_type _ValueTypeI; typedef typename iterator_traits<_OI>::value_type _ValueTypeO; typedef typename iterator_traits<_II>::iterator_category _Category; - const bool __simple = (__is_trivially_copyable<_ValueTypeO>::_M_type + const bool __simple = (__is_trivially_copyable<_ValueTypeI>::_M_type && __is_pointer<_II>::_M_type && __is_pointer<_OI>::_M_type && __are_same<_ValueTypeI, _ValueTypeO>::_M_type); @@ -284,37 +282,42 @@ namespace std return std::__copy<__simple, _Category>::copy(__first, __last, __result); } - template<typename _InputIterator, typename _OutputIterator> - inline _OutputIterator - __copy_ni2(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, __true_type) - { return _OutputIterator(std::__copy_aux(__first, __last, - __result.base())); } + template<bool, bool> + struct __copy_normal + { + template<typename _II, typename _OI> + static _OI + copy_n(_II __first, _II __last, _OI __result) + { return std::__copy_aux(__first, __last, __result); } + }; - template<typename _InputIterator, typename _OutputIterator> - inline _OutputIterator - __copy_ni2(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, __false_type) - { return std::__copy_aux(__first, __last, __result); } + template<> + struct __copy_normal<true, false> + { + template<typename _II, typename _OI> + static _OI + copy_n(_II __first, _II __last, _OI __result) + { return std::__copy_aux(__first.base(), __last.base(), __result); } + }; - template<typename _InputIterator, typename _OutputIterator> - inline _OutputIterator - __copy_ni1(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, __true_type) + template<> + struct __copy_normal<false, true> { - typedef typename _Is_normal_iterator<_OutputIterator>::_Normal __Normal; - return std::__copy_ni2(__first.base(), __last.base(), - __result, __Normal()); - } + template<typename _II, typename _OI> + static _OI + copy_n(_II __first, _II __last, _OI __result) + { return _OI(std::__copy_aux(__first, __last, __result.base())); } + }; - template<typename _InputIterator, typename _OutputIterator> - inline _OutputIterator - __copy_ni1(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, __false_type) + template<> + struct __copy_normal<true, true> { - typedef typename _Is_normal_iterator<_OutputIterator>::_Normal __Normal; - return std::__copy_ni2(__first, __last, __result, __Normal()); - } + template<typename _II, typename _OI> + static _OI + copy_n(_II __first, _II __last, _OI __result) + { return _OI(std::__copy_aux(__first.base(), __last.base(), + __result.base())); } + }; /** * @brief Copies the range [first,last) into result. @@ -343,8 +346,10 @@ namespace std typename iterator_traits<_InputIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); - typedef typename _Is_normal_iterator<_InputIterator>::_Normal __Normal; - return std::__copy_ni1(__first, __last, __result, __Normal()); + const bool __in = __is_normal_iterator<_InputIterator>::_M_type; + const bool __out = __is_normal_iterator<_OutputIterator>::_M_type; + return std::__copy_normal<__in, __out>::copy_n(__first, __last, + __result); } template<bool, typename> @@ -394,7 +399,7 @@ namespace std typedef typename iterator_traits<_BI1>::value_type _ValueType1; typedef typename iterator_traits<_BI2>::value_type _ValueType2; typedef typename iterator_traits<_BI1>::iterator_category _Category; - const bool __simple = (__is_trivially_copyable<_ValueType2>::_M_type + const bool __simple = (__is_trivially_copyable<_ValueType1>::_M_type && __is_pointer<_BI1>::_M_type && __is_pointer<_BI2>::_M_type && __are_same<_ValueType1, _ValueType2>::_M_type); @@ -403,38 +408,44 @@ namespace std __result); } - template <typename _BI1, typename _BI2> - inline _BI2 - __copy_backward_output_normal_iterator(_BI1 __first, _BI1 __last, - _BI2 __result, __true_type) - { return _BI2(std::__copy_backward_aux(__first, __last, __result.base())); } + template<bool, bool> + struct __copy_backward_normal + { + template<typename _BI1, typename _BI2> + static _BI2 + copy_b_n(_BI1 __first, _BI1 __last, _BI2 __result) + { return std::__copy_backward_aux(__first, __last, __result); } + }; - template <typename _BI1, typename _BI2> - inline _BI2 - __copy_backward_output_normal_iterator(_BI1 __first, _BI1 __last, - _BI2 __result, __false_type) - { return std::__copy_backward_aux(__first, __last, __result); } + template<> + struct __copy_backward_normal<true, false> + { + template<typename _BI1, typename _BI2> + static _BI2 + copy_b_n(_BI1 __first, _BI1 __last, _BI2 __result) + { return std::__copy_backward_aux(__first.base(), __last.base(), + __result); } + }; - template <typename _BI1, typename _BI2> - inline _BI2 - __copy_backward_input_normal_iterator(_BI1 __first, _BI1 __last, - _BI2 __result, __true_type) + template<> + struct __copy_backward_normal<false, true> { - typedef typename _Is_normal_iterator<_BI2>::_Normal __Normal; - return std::__copy_backward_output_normal_iterator(__first.base(), - __last.base(), - __result, __Normal()); - } + template<typename _BI1, typename _BI2> + static _BI2 + copy_b_n(_BI1 __first, _BI1 __last, _BI2 __result) + { return _BI2(std::__copy_backward_aux(__first, __last, + __result.base())); } + }; - template <typename _BI1, typename _BI2> - inline _BI2 - __copy_backward_input_normal_iterator(_BI1 __first, _BI1 __last, - _BI2 __result, __false_type) + template<> + struct __copy_backward_normal<true, true> { - typedef typename _Is_normal_iterator<_BI2>::_Normal __Normal; - return std::__copy_backward_output_normal_iterator(__first, __last, - __result, __Normal()); - } + template<typename _BI1, typename _BI2> + static _BI2 + copy_b_n(_BI1 __first, _BI1 __last, _BI2 __result) + { return _BI2(std::__copy_backward_aux(__first.base(), __last.base(), + __result.base())); } + }; /** * @brief Copies the range [first,last) into result. @@ -465,9 +476,10 @@ namespace std typename iterator_traits<_BI2>::value_type>) __glibcxx_requires_valid_range(__first, __last); - typedef typename _Is_normal_iterator<_BI1>::_Normal __Normal; - return std::__copy_backward_input_normal_iterator(__first, __last, - __result, __Normal()); + const bool __bi1 = __is_normal_iterator<_BI1>::_M_type; + const bool __bi2 = __is_normal_iterator<_BI2>::_M_type; + return std::__copy_backward_normal<__bi1, __bi2>::copy_b_n(__first, __last, + __result); } template<bool> diff --git a/libstdc++-v3/include/bits/type_traits.h b/libstdc++-v3/include/bits/type_traits.h index 9b91e5c5c..0a263e5 100644 --- a/libstdc++-v3/include/bits/type_traits.h +++ b/libstdc++-v3/include/bits/type_traits.h @@ -378,26 +378,6 @@ template<> typedef __true_type _Integral; }; -template<typename _Tp> - struct _Is_normal_iterator - { - typedef __false_type _Normal; - }; - -// Forward declaration hack, should really include this from somewhere. -namespace __gnu_cxx -{ - template<typename _Iterator, typename _Container> - class __normal_iterator; -} - -template<typename _Iterator, typename _Container> - struct _Is_normal_iterator< __gnu_cxx::__normal_iterator<_Iterator, - _Container> > - { - typedef __true_type _Normal; - }; - #endif /* _TYPE_TRAITS_H */ // Local Variables: |