Index: include/span =================================================================== --- include/span +++ include/span @@ -222,20 +222,6 @@ _LIBCPP_INLINE_VISIBILITY constexpr span( array& __arr) noexcept : __data{__arr.data()} {} _LIBCPP_INLINE_VISIBILITY constexpr span(const array& __arr) noexcept : __data{__arr.data()} {} - template - inline _LIBCPP_INLINE_VISIBILITY - constexpr span( _Container& __c, - enable_if_t<__is_span_compatible_container<_Container, _Tp>::value, nullptr_t> = nullptr) - : __data{_VSTD::data(__c)} - { _LIBCPP_ASSERT(_Extent == _VSTD::size(__c), "size mismatch in span's constructor (container)"); } - - template - inline _LIBCPP_INLINE_VISIBILITY - constexpr span(const _Container& __c, - enable_if_t<__is_span_compatible_container::value, nullptr_t> = nullptr) - : __data{_VSTD::data(__c)} - { _LIBCPP_ASSERT(_Extent == _VSTD::size(__c), "size mismatch in span's constructor (const container)"); } - template inline _LIBCPP_INLINE_VISIBILITY constexpr span(const span<_OtherElementType, _Extent>& __other, Index: test/std/containers/views/span.cons/container.fail.cpp =================================================================== --- test/std/containers/views/span.cons/container.fail.cpp +++ test/std/containers/views/span.cons/container.fail.cpp @@ -16,6 +16,7 @@ // constexpr span(const Container& cont); // // Remarks: These constructors shall not participate in overload resolution unless: +// — extent == dynamic_extent, // — Container is not a specialization of span, // — Container is not a specialization of array, // — is_array_v is false, @@ -69,27 +70,19 @@ // Making non-const spans from const sources (a temporary binds to `const &`) { std::span s1{IsAContainer()}; // expected-error {{no matching constructor for initialization of 'std::span'}} - std::span s2{IsAContainer()}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span s3{std::vector()}; // expected-error {{no matching constructor for initialization of 'std::span'}} - std::span s4{std::vector()}; // expected-error {{no matching constructor for initialization of 'std::span'}} } // Missing size and/or data { std::span s1{NotAContainerNoData()}; // expected-error {{no matching constructor for initialization of 'std::span'}} - std::span s2{NotAContainerNoData()}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span s3{NotAContainerNoSize()}; // expected-error {{no matching constructor for initialization of 'std::span'}} - std::span s4{NotAContainerNoSize()}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span s5{NotAContainerPrivate()}; // expected-error {{no matching constructor for initialization of 'std::span'}} - std::span s6{NotAContainerPrivate()}; // expected-error {{no matching constructor for initialization of 'std::span'}} // Again with the standard containers std::span s11{std::deque()}; // expected-error {{no matching constructor for initialization of 'std::span'}} - std::span s12{std::deque()}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span s13{std::list()}; // expected-error {{no matching constructor for initialization of 'std::span'}} - std::span s14{std::list()}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span s15{std::forward_list()}; // expected-error {{no matching constructor for initialization of 'std::span'}} - std::span s16{std::forward_list()}; // expected-error {{no matching constructor for initialization of 'std::span'}} } // Not the same type @@ -96,10 +89,9 @@ { IsAContainer c; std::span s1{c}; // expected-error {{no matching constructor for initialization of 'std::span'}} - std::span s2{c}; // expected-error {{no matching constructor for initialization of 'std::span'}} } -// CV wrong (dynamically sized) +// CV wrong { IsAContainer c; IsAContainer cv; @@ -114,19 +106,9 @@ std::span< volatile int> s7{cv}; // expected-error {{no matching constructor for initialization of 'std::span'}} } -// CV wrong (statically sized) +// statically sized { - IsAContainer c; - IsAContainer cv; - IsAContainer< volatile int> v; - - std::span< int,1> s1{c}; // expected-error {{no matching constructor for initialization of 'std::span'}} - std::span< int,1> s2{v}; // expected-error {{no matching constructor for initialization of 'std::span'}} - std::span< int,1> s3{cv}; // expected-error {{no matching constructor for initialization of 'std::span'}} - std::span s4{v}; // expected-error {{no matching constructor for initialization of 'std::span'}} - std::span s5{cv}; // expected-error {{no matching constructor for initialization of 'std::span'}} - std::span< volatile int,1> s6{c}; // expected-error {{no matching constructor for initialization of 'std::span'}} - std::span< volatile int,1> s7{cv}; // expected-error {{no matching constructor for initialization of 'std::span'}} + IsAContainer c; + std::span s1{c}; // expected-error {{no matching constructor for initialization of 'std::span'}} } - } Index: test/std/containers/views/span.cons/container.pass.cpp =================================================================== --- test/std/containers/views/span.cons/container.pass.cpp +++ test/std/containers/views/span.cons/container.pass.cpp @@ -16,6 +16,7 @@ // constexpr span(const Container& cont); // // Remarks: These constructors shall not participate in overload resolution unless: +// — extent == dynamic_extent, // — Container is not a specialization of span, // — Container is not a specialization of array, // — is_array_v is false, @@ -48,18 +49,13 @@ { std::vector v = {1,2,3}; -// Types the same (dynamic sized) +// Types the same { std::span< int> s1{v}; // a span< int> pointing at int. } -// Types the same (static sized) +// types different { - std::span< int,3> s1{v}; // a span< int> pointing at int. - } - -// types different (dynamic sized) - { std::span s1{v}; // a span pointing at int. std::span< volatile int> s2{v}; // a span< volatile int> pointing at int. std::span< volatile int> s3{v}; // a span< volatile int> pointing at const int. @@ -66,24 +62,12 @@ std::span s4{v}; // a span pointing at int. } -// types different (static sized) - { - std::span s1{v}; // a span pointing at int. - std::span< volatile int,3> s2{v}; // a span< volatile int> pointing at int. - std::span< volatile int,3> s3{v}; // a span< volatile int> pointing at const int. - std::span s4{v}; // a span pointing at int. - } - // Constructing a const view from a temporary { std::span s1{IsAContainer()}; - std::span s2{IsAContainer()}; std::span s3{std::vector()}; - std::span s4{std::vector()}; (void) s1; - (void) s2; (void) s3; - (void) s4; } } @@ -92,11 +76,8 @@ constexpr bool testConstexprSpan() { constexpr IsAContainer val{}; - std::span s1{val}; - std::span s2{val}; - return - s1.data() == val.getV() && s1.size() == 1 - && s2.data() == val.getV() && s2.size() == 1; + std::span s1{val}; + return s1.data() == val.getV() && s1.size() == 1; } @@ -107,12 +88,8 @@ const IsAContainer cVal; std::span s1{val}; std::span s2{cVal}; - std::span s3{val}; - std::span s4{cVal}; assert(s1.data() == val.getV() && s1.size() == 1); assert(s2.data() == cVal.getV() && s2.size() == 1); - assert(s3.data() == val.getV() && s3.size() == 1); - assert(s4.data() == cVal.getV() && s4.size() == 1); } struct A{};