引自C++标准库:教程和手册:
目前使用模板的唯一可移植方法是使用内联函数在头文件中实现它们.
为什么是这样?
(澄清:头文件不是唯一的便携式解决方案.但它们是最方便的便携式解决方案.)
c++ templates c++-faq
我遇到了以下代码片段:
template <typename T, typename = void> struct test { int t = sizeof(T); };
我知道在typename = void, void 是默认参数,但它没有名称!它有什么用处,它甚至意味着什么?
typename = void
c++
c++ ×2
c++-faq ×1
templates ×1