|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | +<meta charset="utf-8"> |
| 5 | +<title>Issue 4228: Does vector<bool, Allocator> mandate that Allocator::value_type is bool?</title> |
| 6 | +<meta property="og:title" content="Issue 4228: Does vector<bool, Allocator> mandate that Allocator::value_type is bool?"> |
| 7 | +<meta property="og:description" content="C++ library issue. Status: New"> |
| 8 | +<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4228.html"> |
| 9 | +<meta property="og:type" content="website"> |
| 10 | +<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png"> |
| 11 | +<meta property="og:image:alt" content="C++ logo"> |
| 12 | +<style> |
| 13 | + p {text-align:justify} |
| 14 | + li {text-align:justify} |
| 15 | + pre code.backtick::before { content: "`" } |
| 16 | + pre code.backtick::after { content: "`" } |
| 17 | + blockquote.note |
| 18 | + { |
| 19 | + background-color:#E0E0E0; |
| 20 | + padding-left: 15px; |
| 21 | + padding-right: 15px; |
| 22 | + padding-top: 1px; |
| 23 | + padding-bottom: 1px; |
| 24 | + } |
| 25 | + ins {background-color:#A0FFA0} |
| 26 | + del {background-color:#FFA0A0} |
| 27 | + table.issues-index { border: 1px solid; border-collapse: collapse; } |
| 28 | + table.issues-index th { text-align: center; padding: 4px; border: 1px solid; } |
| 29 | + table.issues-index td { padding: 4px; border: 1px solid; } |
| 30 | + table.issues-index td:nth-child(1) { text-align: right; } |
| 31 | + table.issues-index td:nth-child(2) { text-align: left; } |
| 32 | + table.issues-index td:nth-child(3) { text-align: left; } |
| 33 | + table.issues-index td:nth-child(4) { text-align: left; } |
| 34 | + table.issues-index td:nth-child(5) { text-align: center; } |
| 35 | + table.issues-index td:nth-child(6) { text-align: center; } |
| 36 | + table.issues-index td:nth-child(7) { text-align: left; } |
| 37 | + table.issues-index td:nth-child(5) span.no-pr { color: red; } |
| 38 | + @media (prefers-color-scheme: dark) { |
| 39 | + html { |
| 40 | + color: #ddd; |
| 41 | + background-color: black; |
| 42 | + } |
| 43 | + ins { |
| 44 | + background-color: #225522 |
| 45 | + } |
| 46 | + del { |
| 47 | + background-color: #662222 |
| 48 | + } |
| 49 | + a { |
| 50 | + color: #6af |
| 51 | + } |
| 52 | + a:visited { |
| 53 | + color: #6af |
| 54 | + } |
| 55 | + blockquote.note |
| 56 | + { |
| 57 | + background-color: rgba(255, 255, 255, .10) |
| 58 | + } |
| 59 | + } |
| 60 | +</style> |
| 61 | +</head> |
| 62 | +<body> |
| 63 | +<hr> |
| 64 | +<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#New">New</a> status.</em></p> |
| 65 | +<h3 id="4228"><a href="lwg-active.html#4228">4228</a>. Does <code>vector<bool, Allocator></code> mandate that <code class='backtick'>Allocator::value_type</code> is <code class='backtick'>bool</code>?</h3> |
| 66 | +<p><b>Section:</b> 23.3.12.1 <a href="https://wg21.link/vector.bool.pspc">[vector.bool.pspc]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a> |
| 67 | + <b>Submitter:</b> Stephan T. Lavavej <b>Opened:</b> 2025-03-18 <b>Last modified:</b> 2025-03-22</p> |
| 68 | +<p><b>Priority: </b>Not Prioritized |
| 69 | +</p> |
| 70 | +<p><b>View all other</b> <a href="lwg-index.html#vector.bool.pspc">issues</a> in [vector.bool.pspc].</p> |
| 71 | +<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p> |
| 72 | +<p><b>Discussion:</b></p> |
| 73 | +<p> |
| 74 | +<a href="https://wg21.link/N5008">N5008</a> 23.3.12.1 <a href="https://wg21.link/vector.bool.pspc">[vector.bool.pspc]</a>/2 says: |
| 75 | +</p> |
| 76 | +<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;"> |
| 77 | +<p> |
| 78 | +Unless described below, all operations have the same requirements and semantics as the primary <code class='backtick'>vector</code> template, |
| 79 | +except that operations dealing with the <code class='backtick'>bool</code> value type map to bit values in the container storage and |
| 80 | +<code class='backtick'>allocator_traits::construct</code> (20.2.9.3 <a href="https://wg21.link/allocator.traits.members">[allocator.traits.members]</a>) is not used to construct these values. |
| 81 | +</p> |
| 82 | +</blockquote> |
| 83 | +<p> |
| 84 | +23.2.2.5 <a href="https://wg21.link/container.alloc.reqmts">[container.alloc.reqmts]</a>/5 says: |
| 85 | +</p> |
| 86 | +<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;"> |
| 87 | +<p> |
| 88 | +<i>Mandates</i>: <code class='backtick'>allocator_type::value_type</code> is the same as <code class='backtick'>X::value_type</code>. |
| 89 | +</p> |
| 90 | +</blockquote> |
| 91 | +<p> |
| 92 | +Is <code>vector<bool, allocator<int>></code> forbidden? There's implementation divergence: |
| 93 | +MSVC's STL enforces the mandate, while libc++ and libstdc++ accept this code, discovered while |
| 94 | +running libc++'s tests with MSVC's STL. |
| 95 | +<p/> |
| 96 | +Preferred resolution: I would be satisfied with resolving this as NAD, with a record that LWG believes |
| 97 | +that "all operations have the same requirements" means that the <i>Mandate</i> applies. I suppose that |
| 98 | +an editorial note could also be added to this effect, although I don't believe it's necessary. |
| 99 | +<p/> |
| 100 | +Alternate resolution: If LWG believes that the <i>Mandate</i> does not apply, and that <code>vector<bool></code> |
| 101 | +should be unique among containers in accepting <code>allocator<Anything></code>, then I believe that |
| 102 | +a normative sentence should be added to 23.3.12.1 <a href="https://wg21.link/vector.bool.pspc">[vector.bool.pspc]</a>/2, specifically creating an exemption |
| 103 | +to 23.2.2.5 <a href="https://wg21.link/container.alloc.reqmts">[container.alloc.reqmts]</a>/5. |
| 104 | +</p> |
| 105 | + |
| 106 | + |
| 107 | +<p id="res-4228"><b>Proposed resolution:</b></p> |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | +</body> |
| 114 | +</html> |
0 commit comments