32 lines · cpp
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-exception6//7//===---------------------------------------------------------------------===//8// UNSUPPORTED: c++03, c++11, c++14, c++179 10// <span>11 12// template <class It, class End>13// constexpr explicit(Extent != dynamic_extent) span(It first, End last);14// Requires: [first, last) shall be a valid range.15// If Extent is not equal to dynamic_extent, then last - first shall be equal to Extent.16//17 18#include <cstddef>19#include <iterator>20#include <span>21 22template <class T, std::size_t Extent>23std::span<T, Extent> createImplicitSpan(T* first, T* last) {24 return {first, last}; // expected-error {{chosen constructor is explicit in copy-initialization}}25}26 27void f() {28 // explicit constructor necessary29 int arr[] = {1, 2, 3};30 createImplicitSpan<int, 1>(std::begin(arr), std::end(arr));31}32