Why doesn't iter_swap use swap?

Paolo Carlini pcarlini@suse.de
Tue Aug 24 11:32:00 GMT 2004


chris jefferson wrote:

> #include<iterator>
> using namespace std;
>
> template<class T,class U>
> struct __iter_swap_helper { static void swapy(const T& t,const U& u) 
> {old_iter_swap(t,u);}
> };
>
> template<class T>
> struct __iter_swap_helper<T,T> { static void swapy(const T& t,const T& 
> u) {swap(*t,*u);}
> };
>
> template<class T,class U>
> void new_iter_swap(const T &t,const U &u) {
> foo<iterator_traits<T>::value_type,iterator_traits<U>::value_type>::__iter_swap_helper(t,u); 
>
> }

Something along these lines seems viable, but in this case we should 
exploit __are_same: see stl_algobase.h for many examples...

Paolo.



More information about the Libstdc++ mailing list