Accessing types from dependent base classes

断了今生、忘了曾经 提交于 2019-12-05 00:56:58

As Richard Corden points out, this issue was addressed in the C++ Standard Core Language Defect Reports after the 2003 standard was ratified: How do the keywords typename/template interact with using-declarations?

Proposed resolution (April 2003, revised October 2003):

Add a new paragraph to the bottom of 7.3.3 [namespace.udecl]:

If a using-declaration uses the keyword typename and specifies a dependent name (14.7.2 [temp.dep]), the name introduced by the using-declaration is treated as a typedef-name (7.1.3 [dcl.typedef]).

This text doesn't seem to appear in the Second Edition standard from October 15, 2003.

GCC does not yet implement this resolution, as explained in bug 14258:

------- Comment #3 From Giovanni Bajo 2004-02-27 12:47 [reply] ------- The problem is that our USING_DECL doesn't record the "typename", that is the fact that it is a type which is imported through it. This used to work thanks to the implicit type name extension, I believe.

Duplicate bug 21484 indicates that 'using typename' works on Comeau and Intel compilers. Because MSVC treats all names as dependent, the construct is unnecessary (but permitted) for that compiler.


Fixed in GCC 4.7 on Dec 13 2011!

You didn't include an access specifier (public/protected/private) in the template for Base before declaring the typedef for Base::value_type. As a result, it defaults to private and is not accessible in classes derived from Base.

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