/***************************************************
1. 模板特化按对象类型(类和全局函数)分为两种: 类模板的特化和全局模板函数的特化;2. 按特化的类型分全特化和偏特化(也就是多个模板参数可以选定只特化一个或者多个),全局模板函数的特化不支持偏特化;
3. 全局模板函数的特化需要关注几个重要元素函数返回值 函数名 形参类型、个数和顺序,eg:
template <class T> T max_(const T &, const T &)
4. 类模板的特化需要关注几个重要元素类名,形参类型和个数,形参的顺序倒不重要了;
****************************************************/
#include <string>
#include <iostream>
#include <cstring>
using namespace std;
template <class T> T max_(const T &a, const T &b)
{
return a > b ? a : b;
}
//全特化参数的类型和顺序都需要
template <> const char* max_(const char* const &a,const char* const &b)
{
return strcmp(a,b) >= 0