/*
partial ordering of function templates
*/
#include <iostream>
using namespace std;
class alloc
{
};
template<class T, class Alloc=alloc>
class vector
{
public:
void swap(vector<T, Alloc>&)
{
cout<<"swap()"<<endl;
}
};
#ifdef _STL_FUNCTION_TMPL_PARTIAL_ORDER
template <class T, class Alloc>
inline void swap(vector<T, Alloc>& x, vector<T, Alloc>& y)
{
x.swap(y);
}
#endif
int main()
{
vector<int> x;
vector<int> y;
swap(x, y);
system("pause");
return 0;
}
STL源码剖析:partial ordering of function templates
最新推荐文章于 2022-09-13 16:45:01 发布