Skip to content

Does libc++'s span have a non-standard converting constructor? #94364

@ldionne

Description

@ldionne

I just came across these constructors which I can't find anywhere in the Standard:

template <__span_array_convertible<element_type> _OtherElementType>
_LIBCPP_HIDE_FROM_ABI constexpr span(const span<_OtherElementType, _Extent>& __other) : __data_{__other.data()} {}
template <__span_array_convertible<element_type> _OtherElementType>
_LIBCPP_HIDE_FROM_ABI constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other) noexcept
: __data_{__other.data()} {
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(_Extent == __other.size(), "size mismatch in span's constructor (other span)");
}

Are they non-standard constructors we provide?

Also, it is possible that the constructor at line 297 is missing a noexcept (thanks @mclow for the heads up).

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions