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> last() const;
14 //
15 // Mandates: Count <= Extent is true.
16
17 #include <span>
18 #include <cstddef>
19
f()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.last<5>(); // expected-error@span:* {{span<T, N>::last<Count>(): Count out of range}}
26
27 // Count numeric_limits
28 [[maybe_unused]] auto s2 = sp.last<std::size_t(-1)>(); // expected-error@span:* {{span<T, N>::last<Count>(): Count out of range}}
29 }
30