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<size_t Count> 13 // constexpr span<element_type, Count> first() const; 14 // 15 // Requires: Count <= size(). 16 17 #include <span> 18 #include <cstddef> 19 20 void f() { 21 int array[] = {1, 2, 3, 4}; 22 std::span<const int, 4> sp(array); 23 24 // Count too large 25 [[maybe_unused]] auto s1 = sp.first<5>(); // expected-error@span:* {{span<T, N>::first<Count>(): Count out of range}} 26 27 // Count numeric_limits 28 [[maybe_unused]] auto s2 = sp.first<std::size_t(-1)>(); // expected-error@span:* {{span<T, N>::first<Count>(): Count out of range}} 29 } 30