File tree Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 107
107
// changed according to the global C locale
108
108
\end {codeblock }
109
109
110
+ \rSec 2[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
\rSec 1[diff.cpp20]{\Cpp {} and ISO \CppXX {}}
111
136
112
137
\rSec 2[diff.cpp20.general]{General}
Original file line number Diff line number Diff line change 18221
18221
18222
18222
\indexheader{span}%
18223
18223
\begin{codeblock}
18224
+ #include <initializer_list> // see \ref{initializer.list.syn}
18225
+
18224
18226
namespace std {
18225
18227
// constants
18226
18228
inline constexpr size_t @\libglobal{dynamic_extent}@ = numeric_limits<size_t>::max();
18292
18294
constexpr span(const array<T, N>& arr) noexcept;
18293
18295
template<class R>
18294
18296
constexpr explicit(extent != dynamic_extent) span(R&& r);
18297
+ constexpr explicit(extent != dynamic_extent) span(std::initializer_list<value_type> il);
18295
18298
constexpr span(const span& other) noexcept = default;
18296
18299
template<class OtherElementType, size_t OtherExtent>
18297
18300
constexpr explicit(@\seebelow@) span(const span<OtherElementType, OtherExtent>& s) noexcept;
18542
18545
What and when \tcode{ranges::data(r)} and \tcode{ranges::size(r)} throw.
18543
18546
\end{itemdescr}
18544
18547
18548
+ \indexlibraryctor{span}%
18549
+ \begin{itemdecl}
18550
+ constexpr explicit(extent != dynamic_extent) span(std::initializer_list<value_type> il);
18551
+ \end{itemdecl}
18552
+
18553
+ \begin{itemdescr}
18554
+ \pnum
18555
+ \constraints
18556
+ \tcode{is_const_v<element_type>} is \tcode{true}.
18557
+
18558
+ \pnum
18559
+ \expects
18560
+ If \tcode{extent} is not equal to \tcode{dynamic_extent}, then
18561
+ \tcode{il.size()} is equal to \tcode{extent}.
18562
+
18563
+ \pnum
18564
+ \effects
18565
+ Initializes \exposid{data_} with \tcode{il.begin()} and
18566
+ \exposid{size_} with \tcode{il.size()}.
18567
+ \end{itemdescr}
18568
+
18545
18569
\indexlibraryctor{span}%
18546
18570
\begin{itemdecl}
18547
18571
constexpr span(const span& other) noexcept = default;
Original file line number Diff line number Diff line change 762
762
#define @\defnlibxname {cpp_lib_smart_ptr_owner_equality}@ 202306L // also in \libheader {memory}
763
763
#define @\defnlibxname {cpp_lib_source_location}@ 201907L // freestanding, also in \libheader {source_location}
764
764
#define @\defnlibxname {cpp_lib_span}@ 202002L // also in \libheader {span}
765
+ #define @\defnlibxname {cpp_lib_span_initializer_list}@ 202311L // also in \libheader {span}
765
766
#define @\defnlibxname {cpp_lib_spanstream}@ 202106L // also in \libheader {spanstream}
766
767
#define @\defnlibxname {cpp_lib_ssize}@ 201902L // freestanding, also in \libheader {iterator}
767
768
#define @\defnlibxname {cpp_lib_sstream_from_string_view}@ 202306L // also in \libheader {sstream}
You can’t perform that action at this time.
0 commit comments