F
Frederick Gotham
The following won't compile for me with any of my compilers:
template<class SpecialType>
class MyClass {};
int main()
{
MyClass<int>::SpecialType obj;
}
The following compiles with Microsoft Visual C++, but I get a build error
with g++. According to the Standard, should it compile?
template<class SpecialType>
class MyClass {
public:
typedef SpecialType SpecialType;
};
int main()
{
MyClass<int>::SpecialType obj;
}
If the Standard forbids this, then the less favourable work-around would
be:
template<class SpecialType_T>
class MyClass {
public:
typedef SpecialType_T SpecialType;
};
int main()
{
MyClass<int>::SpecialType obj;
}
But I don't want to do that until I know whether the Standard forbids my
second code snippet above.
(I'm writing reusable code, and at some point in the future, I may change
the internals so that "SpecialType" no longer coincides with the template
parameter, which is why I have the client write:
MyClass<int>::SpecialType obj;
rather than simply:
int obj;
template<class SpecialType>
class MyClass {};
int main()
{
MyClass<int>::SpecialType obj;
}
The following compiles with Microsoft Visual C++, but I get a build error
with g++. According to the Standard, should it compile?
template<class SpecialType>
class MyClass {
public:
typedef SpecialType SpecialType;
};
int main()
{
MyClass<int>::SpecialType obj;
}
If the Standard forbids this, then the less favourable work-around would
be:
template<class SpecialType_T>
class MyClass {
public:
typedef SpecialType_T SpecialType;
};
int main()
{
MyClass<int>::SpecialType obj;
}
But I don't want to do that until I know whether the Standard forbids my
second code snippet above.
(I'm writing reusable code, and at some point in the future, I may change
the internals so that "SpecialType" no longer coincides with the template
parameter, which is why I have the client write:
MyClass<int>::SpecialType obj;
rather than simply:
int obj;