Can a parameter of a template template parameter cause shadowing?

人走茶凉 提交于 2019-12-01 15:43:28

问题


Is this legal C++?

template <typename T, template <typename T> class>
struct S { };

Clang (3.7.1) rejects it, complaining the second T shadows the first T. GCC seems not to care about it and I think that's reasonable. I think it is only the number of parameters that matters in a template template parameter.

  • http://goo.gl/51bHVG (gcc.godbolt.org)

回答1:


No. [temp.local]/6:

A template-parameter shall not be redeclared within its scope (including nested scopes).



来源:https://stackoverflow.com/questions/35744299/can-a-parameter-of-a-template-template-parameter-cause-shadowing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!