关于模板使用的错误
#include<iostream>using namespace std;
template <typename T>
void merge_sort_aux( int * first ,int * last ,int* temp)
{
int* mid = first +(last - first)/2;
if(first >= mid)
return ;
merge_sort(first , mid , temp);
merge_sort(mid , first, temp);
std::merge(temp ,first , mid ,mid ,last);
std::copy(temp,temp + (last - first ), first);
}
template <typename T>
void merge_sort(int * first ,int * last)
{
int * temp = new int[last - first];
merge_sort_aux(first ,last , temp);
delete[] temp;
}
int main()
{ int *num = new int[6];
for(int i = 0 ; i < 5 ;++i)
cin>>num[i];
merge_sort(num , num+5);
for(i = 0 ; i < 5 ;++i)
cout<<num[i]<<" ";
cout<<endl;
return 0;
}