Title
Can a map's key_type be const?
Status
nad
Section
[associative.reqmts]
Submitter
Judy Ward

Created on 2000-02-29.00:00:00 last changed 172 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

The "key is assignable" requirement from table 69 in [associative.reqmts] already implies the key cannot be const.

Date: 2000-02-29.00:00:00

A user noticed that this doesn't compile with the Rogue Wave library because the rb_tree class declares a key_allocator, and allocator<const int> is not legal, I think:

map < const int, ... > // legal?

which made me wonder whether it is legal for a map's key_type to be const. In email from Matt Austern he said:

I'm not sure whether it's legal to declare a map with a const key type. I hadn't thought about that question until a couple weeks ago. My intuitive feeling is that it ought not to be allowed, and that the standard ought to say so. It does turn out to work in SGI's library, though, and someone in the compiler group even used it. Perhaps this deserves to be written up as an issue too.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg1880
2000-02-29 00:00:00admincreate