2 //===------------------------------ span ---------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===---------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
13 // template<size_t Count>
14 // constexpr span<element_type, Count> first() const;
16 // constexpr span<element_type, dynamic_extent> first(size_type count) const;
18 // Requires: Count <= size().
22 #include "test_macros.h"
24 constexpr int carr
[] = {1, 2, 3, 4};
26 int main(int, char**) {
27 std::span
<const int, 4> sp(carr
);
31 [[maybe_unused
]] auto s1
= sp
.first
<5>(); // expected-error-re@span:* {{static_assert failed{{( due to requirement '.*')?}} "Count out of range in span::first()"}}
34 // Count numeric_limits
36 [[maybe_unused
]] auto s1
= sp
.first
<std::size_t(-1)>(); // expected-error-re@span:* {{static_assert failed{{( due to requirement '.*')?}} "Count out of range in span::first()"}}