|
107 | 107 | // changed according to the global C locale
|
108 | 108 | \end{codeblock}
|
109 | 109 |
|
| 110 | +\rSec2[diff.cpp23.containers]{\ref{containers}: containers library} |
| 111 | + |
| 112 | +\diffref{span.overview} |
| 113 | +\change |
| 114 | +\tcode{span<const T>} is constructible from \tcode{initializer_list<T>}. |
| 115 | +\rationale |
| 116 | +Permit passing a braced initializer list to a function taking \tcode{span}. |
| 117 | +\effect |
| 118 | +Valid \CppXXIII{} code that relies on the lack of this constructor |
| 119 | +may refuse to compile, or change behavior in this revision of \Cpp{}. |
| 120 | +For example: |
| 121 | +\begin{codeblock} |
| 122 | +void one(pair<int, int>); // \#1 |
| 123 | +void one(span<const int>); // \#2 |
| 124 | +void t1() { one({1, 2}); } // ambiguous between \#1 and \#2; previously called \#1 |
| 125 | + |
| 126 | +void two(span<const int, 2>); |
| 127 | +void t2() { two({{1, 2}}); } // ill-formed; previously well-formed |
| 128 | + |
| 129 | +void *a[10]; |
| 130 | +int x = span<void* const>{a, 0}.size(); // \tcode{x} is \tcode{2}; previously \tcode{0} |
| 131 | +any b[10]; |
| 132 | +int y = span<const any>{b, b + 10}.size(); // \tcode{y} is \tcode{2}; previously \tcode{10} |
| 133 | +\end{codeblock} |
| 134 | + |
110 | 135 | \rSec2[diff.cpp23.depr]{\ref{depr}: compatibility features}
|
111 | 136 |
|
112 | 137 | \nodiffref
|
|
129 | 154 | // OK in \CppXXVI{}
|
130 | 155 | \end{codeblock}
|
131 | 156 |
|
132 |
| -\rSec2[diff.cpp23.containers]{\ref{containers}: containers library} |
133 |
| - |
134 |
| -\diffref{span.overview} |
| 157 | +\nodiffref |
135 | 158 | \change
|
136 |
| -\tcode{span<const T>} is constructible from \tcode{initializer_list<T>}. |
| 159 | +Remove the \tcode{basic_string::reserve()} overload with no parameters. |
137 | 160 | \rationale
|
138 |
| -Permit passing a braced initializer list to a function taking \tcode{span}. |
| 161 | +The overload of \tcode{reserve} with no parameters is redundant. |
| 162 | +The \tcode{shrink_to_fit} member function can be used instead. |
139 | 163 | \effect
|
140 |
| -Valid \CppXXIII{} code that relies on the lack of this constructor |
141 |
| -may refuse to compile, or change behavior in this revision of \Cpp{}. |
142 |
| -For example: |
143 |
| -\begin{codeblock} |
144 |
| -void one(pair<int, int>); // \#1 |
145 |
| -void one(span<const int>); // \#2 |
146 |
| -void t1() { one({1, 2}); } // ambiguous between \#1 and \#2; previously called \#1 |
147 |
| - |
148 |
| -void two(span<const int, 2>); |
149 |
| -void t2() { two({{1, 2}}); } // ill-formed; previously well-formed |
150 |
| - |
151 |
| -void *a[10]; |
152 |
| -int x = span<void* const>{a, 0}.size(); // \tcode{x} is \tcode{2}; previously \tcode{0} |
153 |
| -any b[10]; |
154 |
| -int y = span<const any>{b, b + 10}.size(); // \tcode{y} is \tcode{2}; previously \tcode{10} |
155 |
| -\end{codeblock} |
| 164 | +A valid \CppXXIII{} program that calls \tcode{reserve()} |
| 165 | +on a \tcode{basic_string} object may fail to compile. |
| 166 | +The old functionality can be achieved by calling \tcode{shrink_to_fit()} instead, |
| 167 | +or the function call can be safely eliminated with no side effects. |
156 | 168 |
|
157 | 169 | \rSec1[diff.cpp20]{\Cpp{} and ISO \CppXX{}}
|
158 | 170 |
|
|
0 commit comments