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

4228. Does vector<bool, Allocator> mandate that Allocator::value_type is bool?

Section: 23.3.14.1 [vector.bool.pspc] Status: New Submitter: Stephan T. Lavavej Opened: 2025-03-18 Last modified: 2025-03-22

Priority: Not Prioritized

View all other issues in [vector.bool.pspc].

View all issues with New status.

Discussion:

N5008 23.3.14.1 [vector.bool.pspc]/2 says:

Unless described below, all operations have the same requirements and semantics as the primary vector template, except that operations dealing with the bool value type map to bit values in the container storage and allocator_traits::construct (20.2.9.3 [allocator.traits.members]) is not used to construct these values.

23.2.2.5 [container.alloc.reqmts]/5 says:

Mandates: allocator_type::value_type is the same as X::value_type.

Is vector<bool, allocator<int>> forbidden? There's implementation divergence: MSVC's STL enforces the mandate, while libc++ and libstdc++ accept this code, discovered while running libc++'s tests with MSVC's STL.

Preferred resolution: I would be satisfied with resolving this as NAD, with a record that LWG believes that "all operations have the same requirements" means that the Mandate applies. I suppose that an editorial note could also be added to this effect, although I don't believe it's necessary.

Alternate resolution: If LWG believes that the Mandate does not apply, and that vector<bool> should be unique among containers in accepting allocator<Anything>, then I believe that a normative sentence should be added to 23.3.14.1 [vector.bool.pspc]/2, specifically creating an exemption to 23.2.2.5 [container.alloc.reqmts]/5.

Proposed resolution: