program files (x86)\microsoft visual studio 14.0\vc\include\xtree,如果没有找到,下标溢出了,就报错咯

---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Debug Assertion Failed!

Program: C:\Windows\SYSTEM32\MSVCP140D.dll
File: d:\program files (x86)\microsoft visual studio 14.0\vc\include\xtree
Line: 238

Expression: map/set iterator not dereferencable

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)

---------------------------
中止(A) 重试(R) 忽略(I)
---------------------------

int main()
{
//set<string> names;//不写,是默认的二元谓词,区分大小写
set<string,CCompareStringNoCase> names;//不区分大小写,二元谓词可以改变容器的默认的行为
//cout << "hello" << endl;
names.insert("Tina");
names.insert("jim");
names.insert("Jack");
names.insert("Sam");
names.insert("hello");
//set<string>::iterator iNameFound = names.find("Jim");
set<string,CCompareStringNoCase>::iterator iNameFound = names.find("1im");
if (iNameFound != names.end())
{
cout << "找到了。。。" << *iNameFound << endl;
}
else
{
cout << "没找到。。。" << endl;
//cout << "没找到。。。" << *iNameFound << endl;//----------------------------如果没有找到,下标溢出了,就报错咯
}
getchar();
return 0;
}

欢迎讨论,相互学习。 txwtech@163.com
原文地址:https://www.cnblogs.com/txwtech/p/12114557.html