brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 176ca20 Raw
44 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>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// constexpr explicit(extent != dynamic_extent) span(std::initializer_list<value_type> il); // Since C++2617 18#include <span>19#include <cstddef>20 21#include "test_macros.h"22 23template <class T, std::size_t extent>24std::span<T, extent> createImplicitSpan(T* ptr, std::size_t len) {25  return {ptr, len}; // expected-error {{chosen constructor is explicit in copy-initialization}}26}27 28void test() {29  // explicit constructor necessary30  int arr[] = {1, 2, 3};31  createImplicitSpan<int, 1>(arr, 3);32 33  // expected-error@+1 {{no matching constructor for initialization of 'std::span<int>'}}34  std::span<int> sp = {0, 0};35  // expected-error@+1 {{no matching constructor for initialization of 'std::span<int, 2>'}}36  std::span<int, 2> sp2 = {0, 0};37#if TEST_STD_VER < 2638  // expected-error@+1 {{no matching constructor for initialization of 'std::span<const int>'}}39  std::span<const int> csp = {0, 0};40  // expected-error@+1 {{no matching constructor for initialization of 'std::span<const int, 2>'}}41  std::span<const int, 2> csp2 = {0, 0};42#endif43}44