Skip to content

Commit

Permalink
[diff.cpp23] Fix order of subclauses.
Browse files Browse the repository at this point in the history
This was accidentally broken by the application of the previous motion.
  • Loading branch information
tkoeppe committed Dec 17, 2023
1 parent 8862c9e commit 568e49f
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions source/compatibility.tex
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,31 @@
// changed according to the global C locale
\end{codeblock}

\rSec2[diff.cpp23.containers]{\ref{containers}: containers library}

\diffref{span.overview}
\change
\tcode{span<const T>} is constructible from \tcode{initializer_list<T>}.
\rationale
Permit passing a braced initializer list to a function taking \tcode{span}.
\effect
Valid \CppXXIII{} code that relies on the lack of this constructor
may refuse to compile, or change behavior in this revision of \Cpp{}.
For example:
\begin{codeblock}
void one(pair<int, int>); // \#1
void one(span<const int>); // \#2
void t1() { one({1, 2}); } // ambiguous between \#1 and \#2; previously called \#1

void two(span<const int, 2>);
void t2() { two({{1, 2}}); } // ill-formed; previously well-formed

void *a[10];
int x = span<void* const>{a, 0}.size(); // \tcode{x} is \tcode{2}; previously \tcode{0}
any b[10];
int y = span<const any>{b, b + 10}.size(); // \tcode{y} is \tcode{2}; previously \tcode{10}
\end{codeblock}

\rSec2[diff.cpp23.depr]{\ref{depr}: compatibility features}

\nodiffref
Expand Down Expand Up @@ -141,31 +166,6 @@
The old functionality can be achieved by calling \tcode{shrink_to_fit()} instead,
or the function call can be safely eliminated with no side effects.

\rSec2[diff.cpp23.containers]{\ref{containers}: containers library}

\diffref{span.overview}
\change
\tcode{span<const T>} is constructible from \tcode{initializer_list<T>}.
\rationale
Permit passing a braced initializer list to a function taking \tcode{span}.
\effect
Valid \CppXXIII{} code that relies on the lack of this constructor
may refuse to compile, or change behavior in this revision of \Cpp{}.
For example:
\begin{codeblock}
void one(pair<int, int>); // \#1
void one(span<const int>); // \#2
void t1() { one({1, 2}); } // ambiguous between \#1 and \#2; previously called \#1

void two(span<const int, 2>);
void t2() { two({{1, 2}}); } // ill-formed; previously well-formed

void *a[10];
int x = span<void* const>{a, 0}.size(); // \tcode{x} is \tcode{2}; previously \tcode{0}
any b[10];
int y = span<const any>{b, b + 10}.size(); // \tcode{y} is \tcode{2}; previously \tcode{10}
\end{codeblock}

\rSec1[diff.cpp20]{\Cpp{} and ISO \CppXX{}}

\rSec2[diff.cpp20.general]{General}
Expand Down

0 comments on commit 568e49f

Please sign in to comment.