实例代码:
#include <iostream>
#include <vector>
#include <map>
using namespace std;
template <typename wt>
struct map_s{
typedef std::map <std::string, wt> type;
};
template<typename T>
using str_map_t = std::map<std::string, T>;
template<typename T>
using myfunc_M = int(*)(T, T);
int RealFunc(int i, int j){
return 1;
}
template<typename T1, typename T2, typename T3>
T1 sum(T1 i, T3 j)
{
T1 result = i + j;
return result;
}
int main()
{
typedef unsigned int uint_t;
uint_t abc;
typedef std::map<std::string, int> map_s_i;
map_s_i mymap;
mymap.insert({ "first", 1 });
mymap.insert({ "second", 2 });
typedef std::map<std::string, std::string> map_s_s;
map_s_s mymap2;
mymap2.insert({ "first", "firstone" });
map_s<int>::type map1;
map1.insert({ "first", 1 });
str_map_t<int> map2;
map1.insert({ "second", 2 });
typedef unsigned int uint_t;
using uint_t = unsigned int;
typedef std::map<std::string, int> map_s_i;
using map_s_i = std::map<std::string, int>;
typedef int(*FunType)(int, int);
using FunType = int(*)(int, int);
myfunc_M<int> pointFunc;
pointFunc = RealFunc;
cout << pointFunc(1, 6) << endl;
auto result = sum<int,int>(20000, 20000);
cout << result << endl;
system("pause");
}