// -*- C++ -*- //===------------------------------ span ---------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===---------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 // // template // constexpr span(element_type (&arr)[N]) noexcept; // template // constexpr span(array& arr) noexcept; // template // constexpr span(const array& arr) noexcept; // // Remarks: These constructors shall not participate in overload resolution unless: // — extent == dynamic_extent || N == extent is true, and // — remove_pointer_t(*)[] is convertible to ElementType(*)[]. // #include #include #include #include "test_macros.h" int arr[] = {1,2,3}; const int carr[] = {4,5,6}; volatile int varr[] = {7,8,9}; const volatile int cvarr[] = {1,3,5}; int main () { // Size wrong { std::span s1(arr); // expected-error {{no matching constructor for initialization of 'std::span'}} } // Type wrong { std::span s1(arr); // expected-error {{no matching constructor for initialization of 'std::span'}} std::span s2(arr); // expected-error {{no matching constructor for initialization of 'std::span'}} } // CV wrong (dynamically sized) { std::span< int> s1{ carr}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span< int> s2{ varr}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span< int> s3{cvarr}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span s4{ varr}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span s5{cvarr}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span< volatile int> s6{ carr}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span< volatile int> s7{cvarr}; // expected-error {{no matching constructor for initialization of 'std::span'}} } // CV wrong (statically sized) { std::span< int,3> s1{ carr}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span< int,3> s2{ varr}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span< int,3> s3{cvarr}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span s4{ varr}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span s5{cvarr}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span< volatile int,3> s6{ carr}; // expected-error {{no matching constructor for initialization of 'std::span'}} std::span< volatile int,3> s7{cvarr}; // expected-error {{no matching constructor for initialization of 'std::span'}} } }