brintos

brintos / llvm-project-archived public Read only

0
0
Text · 969 B · d96bfac Raw
31 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<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 20void f() {21  int array[] = {1, 2, 3, 4};22  std::span<const int, 4> sp(array);23 24  //  Count too large25  [[maybe_unused]] auto s1 = sp.last<5>(); // expected-error@span:* {{span<T, N>::last<Count>(): Count out of range}}26 27  //  Count numeric_limits28  [[maybe_unused]] auto s2 =29      sp.last<std::size_t(-1)>(); // expected-error@span:* {{span<T, N>::last<Count>(): Count out of range}}30}31