This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.

### 215. Can a map's key_type be const?

Section: 22.2.6 [associative.reqmts] Status: NAD Submitter: Judy Ward Opened: 2000-02-29 Last modified: 2016-01-28

Priority: Not Prioritized

View other active issues in [associative.reqmts].

View all other issues in [associative.reqmts].

View all issues with NAD status.

Discussion:

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.

Rationale:

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