C++ c++;模板类澄清

C++ c++;模板类澄清,c++,templates,typedef,C++,Templates,Typedef,为什么我可以以这种方式使用模板类“listmap” 在其中,我可以键入def listmap typedef listmap<string,string> str_str_map; typedef listmap str_str_map; listmap的模板如下所示 template <typename Key, typename Value, class Less=xless<Key>> class listmap 模板 类列表映射 我可以看到字符

为什么我可以以这种方式使用模板类“listmap”

在其中,我可以键入def listmap

typedef listmap<string,string> str_str_map;
typedef listmap str_str_map;
listmap的模板如下所示

template <typename Key, typename Value, class Less=xless<Key>>
class listmap
模板
类列表映射

我可以看到字符串与typename键和typename值对应,但为什么typedef中不需要class Less?

提供了
Less
的默认值,它是类型
xless
。因此,如果不提供第三个参数,您将使用
xless
(在您的情况下)。

class Less=xless
-默认类型,也许?@sashoalm一个愚蠢的问题不会自动使它失效。