当基类是要声明的类的部分专用版本时,导入基类定义的using
声明是否无效?
鉴于代码:
template <typename T> class FullySpecializedBase;
template <> class FullySpecializedBase<void> {
typedef int my_type;
};
template <typename T>
class FullySpecializedBase : FullySpecializedBase<void> {
using typename FullySpecializedBase<void>::my_type;
my_type i;
};
template <> class FullySpecializedBase<int>;
template <typename T, typename V> class PartiallySpecializedBase;
template <typename V> class PartiallySpecializedBase<void, V> {
typedef V my_type;
};
template <typename T, typename V>
class PartiallySpecializedBase : PartiallySpecializedBase<void, V> {
using typename PartiallySpecializedBase<void, V>::my_type;
my_type i;
};
template <> class PartiallySpecializedBase<int, int>;
int main() { return 0; }
使用各种版本的GCC和Clang 3.4.2编译-std=c++98 -pedantic -Wall
PartiallySpecializedBase
将无法在GCC版本上进行编译&lt;由于minimal.cpp:24: error: ‘my_type’ does not name a type
,4.7(测试回到至少4.1.2)。但是,我无法找到特别提到此问题的错误报告(或许多真正的错误报告)。代码是不正确的,还是仅仅是一个长期存在的gcc错误?