休憩の後、更新されたコードを参照してください。
次のテンプレート化されたクラスがあります。
template<class T> class CDFAManListOps
{
static std::list<T>::iterator CDFAManListOps::GetIterator(std::list<T>* list, int pId)
{
}
}
コンパイルしようとすると、
std::list<T>::iterator' : dependent name is not a type 1> prefix with 'typename' to indicate a type
.
しかし、コンパイラのように関数を変更すると、次のように求められます。
static typename std::list<T>::iterator CDFAManListOps::GetIterator(std::list<T>* list, int pId)
コンパイラ (VS12) が次のエラーでクラッシュします。
fatal error C1001: An internal error has occurred in the compiler.
1> (compiler file 'msc1.cpp', line 1443)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
このコードの何が問題なのか分かりますか?
更新:これは、このクラッシュを再現するために取得できる最小量のコード全体です。
#include <list>
template<class T> class CDFAManListOps
{
static typename std::list<T>::iterator CDFAManListOps::GetIterator(std::list<T>* list, int pId)
{
}
static typename std::list<T>::iterator CDFAManListOps::GetIterator(std::list<T>* list, T object)
{
}
};
int main()
{
}
2 つの関数のいずれかを取り出すGetIterator
と、プログラムはコンパイルされ、正常に実行されます。両方の関数が存在する場合にのみ、コンパイラがクラッシュします。これにより、コードの問題が明確になりますか?
(また、Microsoft Connect でバグ レポートを提出し、その状態を把握したい人がいる場合は、ここにリンクを投稿します。)
Microsoft Connect に関するバグ レポートをここに提出しました。
更新: Microsoft は、近い将来、この特定のバグについて何もしないことを決定しました。上記の Microsoft Connect リンクを参照してください。