![](/img/trans.png)
[英]C++ friend class of the same name in different levels of a nested namespace
[英]the friend class point to a class of the same name in a different namespace
对不起,我无法清楚地描述问题。 编译器给出的错误是:
D:\download\tensorflow-master\tensorflow-master\tensorflow\contrib\cmake\build\protobuf\src\protobuf\src\google/protobuf/arena.h(883): error C3855: “Eigen::Map”: type parameter 'MapOption' is incompatible with the declaration
D:\download\tensorflow-master\tensorflow-master\tensorflow\contrib\cmake\build\protobuf\src\protobuf\src\google/protobuf/arena.h(883): error C2976: “Eigen::Map”: too few type arguments
错误来自官方的tensorflow代码,我可以运行用C ++编写的示例程序。 当我尝试将tensorflow代码插入另一个项目时,出现了错误。
template <typename Key, typename T>
friend class Map;
我知道问题是“地图”指向Eigen :: Map,而它需要指向google :: protobuff :: Map。 此外,“地图”的声明位于google :: protobuff命名空间下。 有人遇到过同样的问题吗? 我正在尽力发表明确的声明。 非常感谢!
因此,您不应该:
在声明范围内using namespace
依靠重新定义在标准库或通用库中保留或使用的标识符
两者都会引起名称冲突,后者会引起不可检测的冲突。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.