diff --git a/libcxx/include/span b/libcxx/include/span --- a/libcxx/include/span +++ b/libcxx/include/span @@ -218,7 +218,7 @@ static constexpr size_type extent = _Extent; // [span.cons], span constructors, copy, assignment, and destructor - template = nullptr> + template requires(_Sz == 0) _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr} {} constexpr span (const span&) noexcept = default; @@ -231,46 +231,40 @@ _LIBCPP_INLINE_VISIBILITY constexpr span(element_type (&__arr)[_Extent]) noexcept : __data{__arr} {} - template , nullptr_t> = nullptr> + template requires(is_convertible_v<_OtherElementType(*)[], element_type (*)[]>) _LIBCPP_INLINE_VISIBILITY constexpr span(array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {} - template , nullptr_t> = nullptr> + template requires(is_convertible_v) _LIBCPP_INLINE_VISIBILITY constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {} template _LIBCPP_INLINE_VISIBILITY - constexpr explicit span( _Container& __c, - enable_if_t<__is_span_compatible_container<_Container, _Tp>::value, nullptr_t> = nullptr) + constexpr explicit span( _Container& __c) + requires(__is_span_compatible_container<_Container, _Tp>::value) : __data{_VSTD::data(__c)} { _LIBCPP_ASSERT(_Extent == _VSTD::size(__c), "size mismatch in span's constructor (range)"); } template _LIBCPP_INLINE_VISIBILITY - constexpr explicit span(const _Container& __c, - enable_if_t<__is_span_compatible_container::value, nullptr_t> = nullptr) + constexpr explicit span(const _Container& __c) + requires(__is_span_compatible_container::value) : __data{_VSTD::data(__c)} { _LIBCPP_ASSERT(_Extent == _VSTD::size(__c), "size mismatch in span's constructor (range)"); } template + requires(is_convertible_v<_OtherElementType(*)[], element_type (*)[]>) _LIBCPP_INLINE_VISIBILITY - constexpr span(const span<_OtherElementType, _Extent>& __other, - enable_if_t< - is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, - nullptr_t> = nullptr) + constexpr span(const span<_OtherElementType, _Extent>& __other) : __data{__other.data()} {} template + requires(is_convertible_v<_OtherElementType(*)[], element_type (*)[]>) _LIBCPP_INLINE_VISIBILITY - constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other, - enable_if_t< - is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, - nullptr_t> = nullptr) noexcept + constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other) noexcept : __data{__other.data()} { _LIBCPP_ASSERT(_Extent == __other.size(), "size mismatch in span's constructor (other span)"); } @@ -409,35 +403,33 @@ _LIBCPP_INLINE_VISIBILITY constexpr span(element_type (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {} - template , nullptr_t> = nullptr> + template + requires(is_convertible_v<_OtherElementType(*)[], element_type (*)[]>) _LIBCPP_INLINE_VISIBILITY constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {} - template , nullptr_t> = nullptr> + template + requires(is_convertible_v) _LIBCPP_INLINE_VISIBILITY constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {} template _LIBCPP_INLINE_VISIBILITY - constexpr span( _Container& __c, - enable_if_t<__is_span_compatible_container<_Container, _Tp>::value, nullptr_t> = nullptr) + constexpr span( _Container& __c) + requires(__is_span_compatible_container<_Container, _Tp>::value) : __data{_VSTD::data(__c)}, __size{(size_type) _VSTD::size(__c)} {} template _LIBCPP_INLINE_VISIBILITY - constexpr span(const _Container& __c, - enable_if_t<__is_span_compatible_container::value, nullptr_t> = nullptr) + constexpr span(const _Container& __c) + requires(__is_span_compatible_container::value) : __data{_VSTD::data(__c)}, __size{(size_type) _VSTD::size(__c)} {} template + requires(is_convertible_v<_OtherElementType(*)[], element_type (*)[]>) _LIBCPP_INLINE_VISIBILITY - constexpr span(const span<_OtherElementType, _OtherExtent>& __other, - enable_if_t< - is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, - nullptr_t> = nullptr) noexcept + constexpr span(const span<_OtherElementType, _OtherExtent>& __other) noexcept : __data{__other.data()}, __size{__other.size()} {} // ~span() noexcept = default; @@ -550,10 +542,10 @@ -> decltype(__s.__as_bytes()) { return __s.__as_bytes(); } -template +template requires(!is_const_v<_Tp>) _LIBCPP_INLINE_VISIBILITY auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept --> enable_if_t, decltype(__s.__as_writable_bytes())> +-> decltype(__s.__as_writable_bytes()) { return __s.__as_writable_bytes(); } // Deduction guides