From: Jack on
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
> Can std::map<a,b> m_map;

What the heck...



From: Victor Bazarov on
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
Thanks Victor! Happy New Year.
Jack


From: Stephan T. Lavavej [MSFT] on
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

 |  Next  |  Last
Pages: 1 2
Prev: IEnumerator Question
Next: Deleting only folders