[libcxx-commits] [libcxx] [libc++][span] P2447R4: `std::span` over an initializer list (PR #78157)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jan 15 09:29:04 PST 2024


================
@@ -228,6 +229,14 @@ public:
     requires(_Sz == 0)
   _LIBCPP_HIDE_FROM_ABI constexpr span() noexcept : __data_{nullptr} {}
 
+#  if _LIBCPP_STD_VER >= 26
+  _LIBCPP_HIDE_FROM_ABI constexpr explicit span(std::initializer_list<value_type> __il)
+    requires is_const_v<element_type>
+      : __data_{__il.begin()} {
+    _LIBCPP_ASSERT_INTERNAL(_Extent == __il.size(), "Size mismatch in span's constructor _Extent != __il.size().");
----------------
mordante wrote:

```suggestion
    _LIBCPP_ASSERT_VALID_INPUT_RANGE(_Extent == __il.size(), "Size mismatch in span's constructor _Extent != __il.size().");
```

https://github.com/llvm/llvm-project/pull/78157


More information about the libcxx-commits mailing list