开发者

const_iterator Prolems

开发者 https://www.devze.com 2023-04-02 10:28 出处:网络
I\'ve never used const_iterator before and am having difficulty getting this to debug.Any help is appreciated. Windows 7 and开发者_开发技巧 VS 2010Thank you.

I've never used const_iterator before and am having difficulty getting this to debug. Any help is appreciated. Windows 7 and开发者_开发技巧 VS 2010 Thank you.

typedef std::basic_string <unsigned char> ustring;
ustring receivedData(data[i], length);
typedef std::map<string, int> MapMime;
MapMime mymap;

mymap["audio/basic"] = 1;
mymap["audio/x-aiff"] = 2;
mymap["audio/x-wav"] = 3;
mymap["video/mpeg"] = 4;
mymap["video/mpeg-2"] = 5;
mymap["video/quicktime"] = 6;

for (MapMime::const_iterator it = mymap.begin(), itEnd = mymap.end();it !=   itEnd.++it);
{
size_t findPosition = receivedData.find(it->first);
if (findPosition != string::npos)
    {
    // Found a match at position findPosition
    }
    else
    {
    // That MIME type was not found in the data...
    }
}


You have an extra semicolon after the for loop, you should remove it. Otherwise, 'it' is defined only inside the for loop, which is empty.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号