|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4228" status="New"> |
| 5 | +<title>Does <tt>vector<bool, Allocator></tt> mandate that `Allocator::value_type` is `bool`?</title> |
| 6 | +<section> |
| 7 | +<sref ref="[vector.bool.pspc]"/> |
| 8 | +</section> |
| 9 | +<submitter>Stephan T. Lavavej</submitter> |
| 10 | +<date>18 Mar 2025</date> |
| 11 | +<priority>99</priority> |
| 12 | + |
| 13 | +<discussion> |
| 14 | +<p> |
| 15 | +<paper num="N5008"/> <sref ref="[vector.bool.pspc]"/>/2 says: |
| 16 | +</p> |
| 17 | +<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;"> |
| 18 | +<p> |
| 19 | +Unless described below, all operations have the same requirements and semantics as the primary `vector` template, |
| 20 | +except that operations dealing with the `bool` value type map to bit values in the container storage and |
| 21 | +`allocator_traits::construct` (<sref ref="[allocator.traits.members]"/>) is not used to construct these values. |
| 22 | +</p> |
| 23 | +</blockquote> |
| 24 | +<p> |
| 25 | +<sref ref="[container.alloc.reqmts]"/>/5 says: |
| 26 | +</p> |
| 27 | +<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;"> |
| 28 | +<p> |
| 29 | +<i>Mandates</i>: `allocator_type::value_type` is the same as `X::value_type`. |
| 30 | +</p> |
| 31 | +</blockquote> |
| 32 | +<p> |
| 33 | +Is <tt>vector<bool, allocator<int>></tt> forbidden? There's implementation divergence: |
| 34 | +MSVC's STL enforces the mandate, while libc++ and libstdc++ accept this code, discovered while |
| 35 | +running libc++'s tests with MSVC's STL. |
| 36 | +<p/> |
| 37 | +Preferred resolution: I would be satisfied with resolving this as NAD, with a record that LWG believes |
| 38 | +that "all operations have the same requirements" means that the <i>Mandate</i> applies. I suppose that |
| 39 | +an editorial note could also be added to this effect, although I don't believe it's necessary. |
| 40 | +<p/> |
| 41 | +Alternate resolution: If LWG believes that the <i>Mandate</i> does not apply, and that <tt>vector<bool></tt> |
| 42 | +should be unique among containers in accepting <tt>allocator<Anything></tt>, then I believe that |
| 43 | +a normative sentence should be added to <sref ref="[vector.bool.pspc]"/>/2, specifically creating an exemption |
| 44 | +to <sref ref="[container.alloc.reqmts]"/>/5. |
| 45 | +</p> |
| 46 | +</discussion> |
| 47 | + |
| 48 | +<resolution> |
| 49 | +</resolution> |
| 50 | + |
| 51 | +</issue> |
0 commit comments