1 //===---------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===---------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17
9 
10 // <span>
11 
12 // template <class It>
13 // constexpr explicit(Extent != dynamic_extent) span(It first, size_type count);
14 //  If Extent is not equal to dynamic_extent, then count shall be equal to Extent.
15 //
16 
17 #include <span>
18 #include <cstddef>
19 
20 template <class T, size_t extent>
createImplicitSpan(T * ptr,size_t len)21 std::span<T, extent> createImplicitSpan(T* ptr, size_t len) {
22   return {ptr, len}; // expected-error {{chosen constructor is explicit in copy-initialization}}
23 }
24 
main(int,char **)25 int main(int, char**) {
26   // explicit constructor necessary
27   int arr[] = {1, 2, 3};
28   createImplicitSpan<int, 1>(arr, 3);
29 
30   std::span<int> sp = {0, 0}; // expected-error {{no matching constructor for initialization of 'std::span<int>'}}
31   std::span<int, 2> sp2 = {0, 0}; // expected-error {{no matching constructor for initialization of 'std::span<int, 2>'}}
32   std::span<const int> csp = {0, 0}; // expected-error {{no matching constructor for initialization of 'std::span<const int>'}}
33   std::span<const int, 2> csp2 = {0, 0}; // expected-error {{no matching constructor for initialization of 'std::span<const int, 2>'}}
34 
35   return 0;
36 }
37