c++ - template-parameter-list of template parameter 是什么意思

标签 c++ templates

引用 3.3.9/1 中的一句话:

The declarative region of the name of a template parameter of a template template-parameter is the smallest template-parameter-list in which the name was introduced.

你能举个例子来理解上面的定义吗?我也想知道模板参数的模板参数列表是什么意思?示例会有所帮助。

最佳答案

template< // outer template-parameter-list
    template< // inner template-parameter-list
        typename q, // named parameter of a template template-parameter
        q x // use that name
    > // the declarative region ends here
    class q // hence the name may be reused
> struct x {};

这里再次没有评论,如果这有助于跟进:

template< template< typename q, q x > class q >
struct x {};

它是一个在模板上参数化的类,它采用给定类型的常量值。例如,你可以有 x< std::integral_constant > .

关于c++ - template-parameter-list of template parameter 是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23797487/

相关文章:

iphone - 为 XCode 4 创建 iPhone 项目模板

c++ - stdio.h 在 C++ 中不是标准的?

c++ - CArchive 当前在文件中的位置

c++ - 调整 std::streampos 的老式转换以兼容 g++ 4.4

c++ - 使用 Qt/C++ 等到所有线程在主线程中完成

templates - 在模板中使用空对象,如何避免 NullPointerException?

c++ - 检查数组是否为标量类型

c++ - 确定升压变体中的最大 sizeof()

visual-studio-2010 - VS 2010 多项目模板。你如何引用其他项目名称?

c++ - 相同类型但维度不同的 boost::multi_array 的容器