| | |
STL <map> question?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Hello ladies and gents,
Im reading about working with maps and there is small programm example shown in this chapter. Now, when I write this code into the MS VC C++ compiler and compile the code, I get like over 90 warnings, however, when pressing compile again, they all are gone
Some examples of warning messages:
Questions are:
1) What is causing these warnings the first time I compile?
2) How can I make sure that these warnings aren't shown from the first time I compile the code?
3) Why do those warnings don't appear the second time I compile this code?
Im reading about working with maps and there is small programm example shown in this chapter. Now, when I write this code into the MS VC C++ compiler and compile the code, I get like over 90 warnings, however, when pressing compile again, they all are gone

C++ Syntax (Toggle Plain Text)
#include <iostream> #include <string> #include <map> using namespace std; int main() { typedef map<string, int, less<string> > maptype; maptype M; M["Jan"] = 1234; M["Piet"] = 9999; M["Piet"] = 3456; M["Klaas"] = 5678; for(maptype::iterator i = M.begin(); i != M.end(); ++i) cout<< (*i).first <<" "<< (*i).second <<endl; cout<<"Press any key to continue!\n"; cin.get(); return 0; }
Some examples of warning messages:
C++ Syntax (Toggle Plain Text)
main.cpp c:\program files\microsoft visual studio\vc98\include\xtree(120) : warning C4786: 'std::_Tree<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const , int>,std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,int,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<int> >::_Kfn,std::less<std::basic_string<char,std::char_traits<cha r>,std::allocator<char> > >,std::allocator<int> >' : identifier was truncated to '255' characters in the debug information c:\program files\microsoft visual studio\vc98\include\map(46) : see reference to class template instantiation 'std::_Tree<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::pair<std::basic_string<char,std::char_traits< char>,std::allocator<char> > const ,int>,std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,int,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<int> >::_Kfn,std::less<std::ba sic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<int> >' being compiled C:\Program Files\Microsoft Visual Studio\MyProjects\LAVbBoek\main.cpp(12) : see reference to class template instantiation 'std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,int,std::less<std::basic_string<char,std ::char_traits<char>,std::allocator<char> > >,std::allocator<int> >' being compiled
Questions are:
1) What is causing these warnings the first time I compile?
2) How can I make sure that these warnings aren't shown from the first time I compile the code?
3) Why do those warnings don't appear the second time I compile this code?
>1) What is causing these warnings the first time I compile?
The complete identifier is saved for debugging purposes when you compile in debug mode. However, because the internal identifier for templates can be ridiculously long, and the compiler only allows a length of 255 characters, everything after 255 characters has been cut off. The warning simply notifies you of that, and can be safely ignored.
>2) How can I make sure that these warnings aren't shown from the first time I compile the code?
Compile in release mode, or disable the warning with a pragma:
>3) Why do those warnings don't appear the second time I compile this code?
Probably because no changes were made to the source, so the file wasn't actually compiled because the current compilation was up to date.
The complete identifier is saved for debugging purposes when you compile in debug mode. However, because the internal identifier for templates can be ridiculously long, and the compiler only allows a length of 255 characters, everything after 255 characters has been cut off. The warning simply notifies you of that, and can be safely ignored.
>2) How can I make sure that these warnings aren't shown from the first time I compile the code?
Compile in release mode, or disable the warning with a pragma:
C++ Syntax (Toggle Plain Text)
#pragma warning(disable:4786)
Probably because no changes were made to the source, so the file wasn't actually compiled because the current compilation was up to date.
I'm here to prove you wrong.
Thanks for the additional information gentlemen :!:
Ive got another question and alltough it's not related to <map>, it is related towards STL.
There's a program shown in wich the uses of find_first_of and find_end are explained, now, I understand what find_first_of is doing, but can't figure out what the actual function of find_end is
Output: 2 7
I understand where 2 comes from because comparing a[5] with b[5] puts it on the second place of a, starting from 0.
But, how does 7 becomes the output for find_end, I don't understand, is it also a position that is determined
The explanation that is given isn't really clear and doesn't really make sense, could someone explain what find_end actually does
Ive got another question and alltough it's not related to <map>, it is related towards STL.
There's a program shown in wich the uses of find_first_of and find_end are explained, now, I understand what find_first_of is doing, but can't figure out what the actual function of find_end is
C++ Syntax (Toggle Plain Text)
#include <algorithm> #include <iostream> using namespace std; int main() { int a[10] = {3, 2, 5, 7, 5, 8, 7, 5, 8, 5}, b[2] = {5, 8}, *p1, *p2; p1 = find_first_of(a, a + 10, b, b + 2); p2 = find_end(a, a + 10, b, b + 2); cout<< p1 - a <<" "<< p2 - a <<endl; cout<<"Press any key to continue!\n"; cin.get(); return 0; }
Output: 2 7
I understand where 2 comes from because comparing a[5] with b[5] puts it on the second place of a, starting from 0.
But, how does 7 becomes the output for find_end, I don't understand, is it also a position that is determined

The explanation that is given isn't really clear and doesn't really make sense, could someone explain what find_end actually does
>could someone explain what find_end actually does
find_end is actually the reverse of search. search finds the first occurance of the second range in the first range, and find_end finds the last occurance of the second range in the first range. find_end is admittedly poorly named. This example may make more sense:
search looks for the first occurance of {5, 8}, which is at index 4. find_end does the opposite and looks for the last occurance of {5, 8}, which is at index 7.
find_end is actually the reverse of search. search finds the first occurance of the second range in the first range, and find_end finds the last occurance of the second range in the first range. find_end is admittedly poorly named. This example may make more sense:
C++ Syntax (Toggle Plain Text)
#include <algorithm> #include <iostream> using namespace std; int main() { int a[10] = {3, 2, 5, 7, 5, 8, 7, 5, 8, 5}, b[2] = {5, 8}, *p1, *p2; p1 = search(a, a + 10, b, b + 2); p2 = find_end(a, a + 10, b, b + 2); cout<< p1 - a <<" "<< p2 - a <<endl; return 0; }
I'm here to prove you wrong.
![]() |
Similar Threads
- (was) STL <map> question (C++)
- sorting stl::map (C++)
Other Threads in the C++ Forum
- Previous Thread: TurboC 2.01 on Windows XP
- Next Thread: Midi Library
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node output parameter pointer problem program programming project proxy python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






