//===---------------------------------------------------------------------===// // // 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 explicit(Extent != dynamic_extent) span(R&& r); #include #include #include #include #include #include #include "test_iterators.h" template constexpr void test_from_range() { T val[3]{}; std::span s{val}; assert(s.size() == std::size(val)); assert(s.data() == std::data(val)); } struct A {}; constexpr bool test() { test_from_range(); test_from_range(); test_from_range(); test_from_range(); return true; } static_assert(!std::is_constructible_v, std::vector&>); // wrong type static_assert(!std::is_constructible_v, std::vector&>); // wrong type static_assert(std::is_constructible_v, std::vector&>); // non-borrowed lvalue static_assert(std::is_constructible_v, std::vector&>); // non-borrowed lvalue static_assert(std::is_constructible_v, std::vector&>); // non-borrowed lvalue static_assert(std::is_constructible_v, std::vector&>); // non-borrowed lvalue static_assert(!std::is_constructible_v, const std::vector&>); // non-borrowed const lvalue static_assert(!std::is_constructible_v, const std::vector&>); // non-borrowed const lvalue static_assert(std::is_constructible_v, const std::vector&>); // non-borrowed const lvalue static_assert(std::is_constructible_v, const std::vector&>); // non-borrowed const lvalue static_assert(std::is_constructible_v, std::vector>); // non-borrowed rvalue static_assert(std::is_constructible_v, std::vector>); // non-borrowed rvalue static_assert(!std::is_constructible_v, std::vector&&>); // non-borrowed rvalue static_assert(!std::is_constructible_v, std::vector&&>); // non-borrowed rvalue static_assert(std::is_constructible_v, std::ranges::subrange>>); // contiguous borrowed rvalue static_assert(std::is_constructible_v, std::ranges::subrange>>); // contiguous borrowed rvalue static_assert(!std::is_constructible_v, std::ranges::subrange>>); // non-contiguous borrowed rvalue static_assert(!std::is_constructible_v, std::ranges::subrange>>); // non-contiguous borrowed rvalue using BorrowedContiguousSizedRange = std::string_view; static_assert(std::is_constructible_v, BorrowedContiguousSizedRange>); static_assert(std::is_constructible_v, BorrowedContiguousSizedRange>); static_assert(!std::is_constructible_v, BorrowedContiguousSizedRange>); static_assert(!std::is_constructible_v, BorrowedContiguousSizedRange>); static_assert(std::is_convertible_v>); static_assert(!std::is_convertible_v>); static_assert(!std::is_convertible_v>); static_assert(!std::is_convertible_v>); static_assert(std::is_convertible_v>); static_assert(!std::is_convertible_v>); int main(int, char**) { test(); static_assert(test()); return 0; }