模板化函数语法错误中使用的模板化类中的嵌套类
Nested class in templated class used in templated function syntax error
假设我有以下内容:
template<typename T>
struct Foo
{
public:
class Bar
{
};
};
如果我然后定义函数
template <typename T>
void func(Foo<T>::Bar g) { }
我收到一个错误: 语法错误:标识符"栏">
为什么我会收到错误以及如何解决它以便我可以使用模板化函数。
使用
template <typename T>
void func( typename Foo<T>::Bar g ) { }
否则,编译器不会将构造Foo<T>::Bar
视为类型说明符,而是将其视为表达式。
相关文章:
- 瓦尔格林德报告在 =带有嵌套shared_ptrs的运算符上的读取错误
- MSVC 2017 - 错误 - 如何将模板类 X 的模板成员函数声明为嵌套类 X::Y 的好友
- 错误:#include 在开发C++中嵌套得太深
- C++ 嵌套类模板 错误 C2440 '=':无法从'type'转换为'same type'
- 为什么我收到以下错误:"no match for 'operator=='"?(带模板的嵌套类)
- C 嵌套结构上的 g++ 编译错误
- 访问range_expression中的嵌套元素会返回不完整的映射(段错误)
- 将 for 循环与嵌套的 while 循环并行化时出现 OpenMP 分段错误
- 模板化函数语法错误中使用的模板化类中的嵌套类
- 使用许多嵌套的#include语句对编译器错误进行故障排除
- 可能的 ComputeCPP SYCL 错误读取嵌套缓冲区
- 为什么我在编译中经常出现错误:包含嵌套太深的 C++
- 无法发现嵌套的循环错误
- boost :: fibonacci_heap:带有比较器重新定义圆形定义错误的嵌套定义
- 解决具有嵌套模板化变量的 Visual Studio 内部编译器错误
- 使用嵌套类的LNK错误
- YAML-cpp 解析嵌套映射和序列错误
- 通过指向成员的指针对嵌套访问进行编译时评估期间出现 GCC 错误
- 在正确嵌套错误信息时遇到麻烦
- Ltrace:调用嵌套错误