c++ - 模板模板参数参数名称用法

标签 c++ template-templates

在代码中

template < template<class TTP> class TP > ... // whatever

TTP 在任何地方都可用吗?在标准中找不到关于这些名称所发生情况的任何引用。

最佳答案

[basic.scope.temp]/p1:

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 < template<class T, T t> class TP > class foo {};
//                           ^  ^-----T's scope ends here
//                           |
//                           T can be used here

foo<std::integral_constant> bar;

关于c++ - 模板模板参数参数名称用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28526061/

相关文章:

c++ - CRTP和模板模板?

c++ - 推断/删除模板模板参数的类型

c++ - 在 .cpp 中定义常量 int/char*

c++ - 帮助缓存局部化的载体吗? (C++)

c++ - 包含类型的类型的模板函数重载

c++ - 不指定内部类型的模板模板参数

c++ - 将自身称为模板模板参数的模板类?

c++ - 在 C/C++ 中分配和访问矩阵

C++构造函数调用

c++ - C++11 中 override 和 virtual 的组合