|
|
Wow, that helped. Thanks a lot vmpstr! I would never had guessed that an extra "typename" would have solved this. Thought that since i put "template " in the signature the compiler would be aware of everything concerning "T"'s. But i guess that the "typename map >::iterator" type is kind of complex.. :) Thanks for the help and explanation! ... |
Pete Becker wrote: > >On 2008-11-20 14:40:19 -0500, acehreli@gmail.com said: >> >>On Nov 20, 7:48 am, Juha Nieminen >>joseph cook wrote: >>>>A map is always sorted using std::less >>>> >>>Not always. By default, yes, but you can specify other comparators, e >>g: >>>> >>>std::map>> >>Or at runtime: >>> >>std::map>> >> >Not really. There's a third ... |
The const has nothing to do with it. It's your use of operator[] in the the cout in line 9. That operator returns a reference to the map element. It's possible to change the map byusing this reference. Your const gets in the way of that and you get a compile error. Either: a) don't use const or b) use const ... |
Hi, I am writing code that is using std::map and having a bit of an issue with its performance. > It appears that the std::map is significantly slower searching for an element then a sequential search in a vector. > Has anyone run into this before? > Do you use map.find ? Otherwise post some ... |
I'm using Visual Studio 2005, but i don't think that's (primarily) where I've gone wrong. I was experimenting, trying, by the way, to move into writing my own iterator so that I can learn, ultimately, to write templates: std::map< int, char [12] cm; char str0[12] = {'f','i','r','s','t',' ','t','e','x','t','\0'}; cm[0] = str0; The compiler says about that assignment, left operand must be ... |
|
Hi! What is the canonical way of finding an intersection of two std::maps? i.e. I have std::map |
digz Hi, I am trying to write a program which has two threads one of them write to a map , and the other one deletes entries based on a certain criterion.. first I cannot get the delete portion to work , what am i missing here. also is it possible/correct that the removeKeyValue function acquire the mutex lock only during ... |
Hi, I have a std::map instance that I want to save into harddisk so that I donot have to recompute it each time. The map itself is keyed by a string and the values are pointers to other objects. Is it possible the whole data structure so that it can be loaded later? Thanks |
Hi Folks I know the C++ standard doesn't talk about threads. However I am a little bit curious as to what might or might not happen with a particular scenario I encountered in my project. Its w.r.t to STL containers so I didn't know where else to post. insights appreciated: my application iterates over a stl::map to do some processing on ... |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hey all. I've got a problem I can't seem to figure out. I'm writing a program that deals with money in multiple currencies. In order to define the various currencies, I've created a class called Currency. I then have a map that looks like this: std::map currency; The key to this array is the ... |
Should the following work? It does on some compilers. How can I get it to work on g++ 3.2? On g++ 3.2 it keeps telling me that there is no such function operator << for ostream and pair. But there is! And I can call it! And it works! So why cannot std::copy find it? thanks, Siegfried template ... |
Hi, everybody I'm working with STL container map to store an element. Everything happens well when I've an simple class (whit no inheritance). But if using inherited classes I got some estrangs behaviors Ex. Class1 { public: int value; Class1(int value) { this->value = value; } Class1(); } Class2 : public Class1 { public: int value2; Class2(); Class2(int value1, int value2) ... |
hello! this the code! std::map::iterator iter=transactions.find(transaction); if(iter != transactions.end()) { return iter->second; //return transactions.[transaction]; } else return NULL; How can I get a copy of iter->second?which is the best way? Sercices is a base class and I want a copy of the derived. these objects are proxies for services. the reason i want a copy is becouse I dont want to ... |
2 questions: Given a map defined as std::map stringmap; //How do you access the data_type (string) via an iterator? std::string spoo("doh"); stringmap.insert(std::make_pair(1,spoo)); // I tried this: for(std::map ::iterator it = stringmap.begin(); it != stringmap.end(); ++it) std::cout << *it; But this doesn't compile with error that the operator+ has not been defined .... I think the problem is that the iterator returns ... |
An object of type u32 is the key. A pointer to an object of type temp is the data. Think of it in terms of object types you may understand. std::map m_mymap; For this map, an object of type int is the key and an object of type string is the data. To store some string in the map, you'll ... |
class A{ public: A(){ cout<<"Class A"< > ); }; int main(){ A * a = new A; B * b = new B; vector v; v.push_back(b); map > m; m[a] = v; Test t; t.start(m); return 0; } What does this error ... |
|
I have performed a connected component analysis on an image and now must find the extreme coordinates (both x and y) of each connected component. To do this, I am using an "array of mappings" for "convenience." The array is as follows: top-left x coordinate, top-left y coordinate, bottom-right x coordinate, bottom-right y coordinate. Now I am utterly confused. I need ... |
|
My example: - a map like this: std::map - a method MethodA() that knows the map - a method MethodB() that doesn't know the map but needs the "MyStruct" of one of the elements I tried this way: - MethodB() calls MethodA() with a parameter "MyStruct* p". - MethodA() searches the element in the map using an iterator and "find()". ... |
23. std::map forums.devshed.com |