This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Why doesn't iter_swap use swap?


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]