今天我尝试将模板类传递给模板参数。我的模板类std::map
有四个模板参数,但最后两个是默认参数。
我能够获得以下代码进行编译:
#include <map>
template<typename K, typename V, typename P, typename A,
template<typename Key, typename Value, typename Pr= P, typename All=A> typename C>
struct Map
{
C<K,V,P,A> key;
};
int main(int argc, char**args) {
// That is so annoying!!!
Map<std::string, int, std::less<std::string>, std::map<std::string, int>::allocator_type, std::map> t;
return 0;
}
不幸的是,我不想一直传递最后两个参数。真的是写的太多了。如何在此处使用一些默认模板参数?