//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17 // // template // constexpr span(const span& s) noexcept; // // Remarks: This constructor shall not participate in overload resolution unless: // Extent == dynamic_extent || Extent == OtherExtent is true, and // OtherElementType(*)[] is convertible to ElementType(*)[]. #include #include #include #include "test_macros.h" template TEST_CONSTEXPR_CXX20 void check() { // dynamic -> dynamic { { std::span from; std::span span{from}; ASSERT_NOEXCEPT(std::span(from)); assert(span.data() == nullptr); assert(span.size() == 0); } { From array[3] = {}; std::span from(array); std::span span{from}; ASSERT_NOEXCEPT(std::span(from)); assert(span.data() == array); assert(span.size() == 3); } } // static -> static { { std::span from; std::span span{from}; ASSERT_NOEXCEPT(std::span(from)); assert(span.data() == nullptr); assert(span.size() == 0); } { From array[3] = {}; std::span from(array); std::span span{from}; ASSERT_NOEXCEPT(std::span(from)); assert(span.data() == array); assert(span.size() == 3); } } // static -> dynamic { { std::span from; std::span span{from}; ASSERT_NOEXCEPT(std::span(from)); assert(span.data() == nullptr); assert(span.size() == 0); } { From array[3] = {}; std::span from(array); std::span span{from}; ASSERT_NOEXCEPT(std::span(from)); assert(span.data() == array); assert(span.size() == 3); } } // dynamic -> static (not allowed) } template TEST_CONSTEXPR_CXX20 void check_cvs() { check(); check(); check(); check(); check(); check(); check(); check(); check(); } struct A {}; TEST_CONSTEXPR_CXX20 bool test() { check_cvs(); check_cvs(); check_cvs(); check_cvs(); check_cvs(); return true; } int main(int, char**) { static_assert(test()); test(); return 0; }