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 64
64
// changed according to the global C locale
65
65
\end {codeblock }
66
66
67
+ \rSec 2[diff.cpp23.containers]{\ref {containers }: containers library}
68
+
69
+ \diffref {span.overview }
70
+ \change
71
+ \tcode {span<const T>} is constructible from \tcode {initializer_list<T>}.
72
+ \rationale
73
+ Permit passing a braced initializer list to a function taking \tcode {span}.
74
+ \effect
75
+ Valid \CppXXIII {} code that relies on the lack of this constructor
76
+ may refuse to compile, or change behavior in this revision of \Cpp {}.
77
+ For example:
78
+ \begin {codeblock }
79
+ void one(pair<int, int>); // \# 1
80
+ void one(span<const int>); // \# 2
81
+ void t1() { one({1,2}); } // ambiguous between \# 1 and \# 2; previously called \# 1
82
+
83
+ void two(span<const int, 2>);
84
+ void t2() { two({{1,2}}); } // ill-formed; previously well-formed
85
+
86
+ void *a[10];
87
+ int x = span<void* const>{a, 0}.size(); // \tcode {x} is \tcode {2}; previously \tcode {0}
88
+ any b[10];
89
+ int y = span<const any>{b, b+10}.size(); // \tcode {y} is \tcode {2}; previously \tcode {10}
90
+ \end {codeblock }
91
+
67
92
\rSec 1[diff.cpp20]{\Cpp {} and ISO \CppXX {}}
68
93
69
94
\rSec 2[diff.cpp20.general]{General}
Original file line number Diff line number Diff line change 18218
18218
18219
18219
\indexheader{span}%
18220
18220
\begin{codeblock}
18221
+ #include <initializer_list> // see \ref{initializer.list.syn}
18222
+
18221
18223
namespace std {
18222
18224
// constants
18223
18225
inline constexpr size_t @\libglobal{dynamic_extent}@ = numeric_limits<size_t>::max();
18289
18291
constexpr span(const array<T, N>& arr) noexcept;
18290
18292
template<class R>
18291
18293
constexpr explicit(extent != dynamic_extent) span(R&& r);
18294
+ constexpr explicit(extent != dynamic_extent) span(std::initializer_list<value_type> il);
18292
18295
constexpr span(const span& other) noexcept = default;
18293
18296
template<class OtherElementType, size_t OtherExtent>
18294
18297
constexpr explicit(@\seebelow@) span(const span<OtherElementType, OtherExtent>& s) noexcept;
18533
18536
What and when \tcode{ranges::data(r)} and \tcode{ranges::size(r)} throw.
18534
18537
\end{itemdescr}
18535
18538
18539
+ \indexlibraryctor{span}%
18540
+ \begin{itemdecl}
18541
+ constexpr explicit(extent != dynamic_extent) span(std::initializer_list<value_type> il);
18542
+ \end{itemdecl}
18543
+
18544
+ \begin{itemdescr}
18545
+ \pnum
18546
+ \constraints
18547
+ \tcode{is_const_v<element_type>} is \tcode{true}.
18548
+
18549
+ \pnum
18550
+ \expects
18551
+ If \tcode{extent} is not equal to \tcode{dynamic_extent}, then
18552
+ \tcode{il.size()} is equal to \tcode{extent}.
18553
+
18554
+ \pnum
18555
+ \effects
18556
+ Initializes \exposid{data_} with \tcode{il.begin()} and
18557
+ \exposid{size_} with \tcode{il.size()}.
18558
+ \end{itemdescr}
18559
+
18536
18560
\indexlibraryctor{span}%
18537
18561
\begin{itemdecl}
18538
18562
constexpr span(const span& other) noexcept = default;
Original file line number Diff line number Diff line change 753
753
#define @\defnlibxname {cpp_lib_smart_ptr_owner_equality}@ 202306L // also in \libheader {memory}
754
754
#define @\defnlibxname {cpp_lib_source_location}@ 201907L // freestanding, also in \libheader {source_location}
755
755
#define @\defnlibxname {cpp_lib_span}@ 202002L // also in \libheader {span}
756
+ #define @\defnlibxname {cpp_lib_span_initializer_list}@ 202311L // also in \libheader {span}
756
757
#define @\defnlibxname {cpp_lib_spanstream}@ 202106L // also in \libheader {spanstream}
757
758
#define @\defnlibxname {cpp_lib_ssize}@ 201902L // freestanding, also in \libheader {iterator}
758
759
#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