編譯器(VC8)錯誤是:
錯誤C2680: '的std :: _樹< _Traits> ::迭代':無效目標類型的dynamic_cast
的源代碼,以模擬該錯誤:
[編輯]源固定現在
如何用迭代器強制解決這個問題?
#include <map>
#include <string>
struct tag_data
{
int in;
int on;
std::string sn;
};
class myclass
{
private:
typedef std::map<std::string, tag_data> TypeData;
TypeData MapStorage;
typedef std::map<unsigned long, TypeData::iterator > TypeToThreadIterMapStorage;
TypeToThreadIterMapStorage ThreadIterMapStorage;
public:
bool find(std::string& k)
{
TypeData::const_iterator theData ;
theData = MapStorage.find(k);
//ThreadIterMapStorage [ 0 ] = MapStorage.begin();// this is ok
ThreadIterMapStorage [ 1 ] = dynamic_cast<TypeData::iterator>(theData); // the error occurs here
return theData != MapStorage.end();
}
virtual ~myclass(){}
};
int _tmain(int argc, _TCHAR* argv[])
{
myclass mc;
return 0;
}
請爲問題添加C++標記... – Ponting 2009-10-27 18:29:34
現在修復了源代碼。 – lsalamon 2009-10-27 18:34:21