Prev: IEnumerator Question
Next: Deleting only folders
From: Jack on 27 Dec 2009 04:40 Can std::map<a,b> m_map; Can the key "a" be any types such as D3DXVECTOR3? Could you please raise an example? Thanks Jack
From: Jack on 27 Dec 2009 05:33 > Can std::map<a,b> m_map; What the heck...
From: Victor Bazarov on 27 Dec 2009 10:41 Jack wrote: > Can std::map<a,b> m_map; > > Can the key "a" be any types such as D3DXVECTOR3? No. There is a set of requirements restricting what can be the key type of a map. For example, the key has to be Less-Than Comparable, IOW there has to exist the operator< (operator "Less Than") defined for that type. > Could you please raise an example? Take any book on standard library containers. GIYF. V -- Please remove capital 'A's when replying by e-mail I do not respond to top-posted replies, please don't ask
From: Jack on 28 Dec 2009 00:43 Thanks Victor! Happy New Year. Jack
From: Stephan T. Lavavej [MSFT] on 4 Jan 2010 14:21
You can also give the map a comparator. For example, map<int, string, greater<int>> sorts its integer keys in reverse order (10, 9, 8). Like with the rest of the STL, you can use any comparator that obeys The Rules. And, of course, your key type has to be copyable, etc. STL "Victor Bazarov" <v.Abazarov(a)comAcast.net> wrote in message news:hh7v7g$dgs$1(a)news.datemas.de... > Jack wrote: >> Can std::map<a,b> m_map; >> >> Can the key "a" be any types such as D3DXVECTOR3? > > No. There is a set of requirements restricting what can be the key type > of a map. For example, the key has to be Less-Than Comparable, IOW there > has to exist the operator< (operator "Less Than") defined for that type. > >> Could you please raise an example? > > Take any book on standard library containers. GIYF. > > V > -- > Please remove capital 'A's when replying by e-mail > I do not respond to top-posted replies, please don't ask |