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 #include <span>
13 #include <cassert>
14 #include <cstddef>
15 
16 struct Sink {
17     constexpr Sink() = default;
SinkSink18     constexpr Sink(Sink*) {}
19 };
20 
count(std::span<const Sink> sp)21 constexpr std::size_t count(std::span<const Sink> sp) {
22     return sp.size();
23 }
24 
25 template<int N>
countn(std::span<const Sink,N> sp)26 constexpr std::size_t countn(std::span<const Sink, N> sp) {
27     return sp.size();
28 }
29 
test()30 constexpr bool test() {
31     Sink a[10];
32     assert(count({a}) == 10);
33     assert(count({a, a+10}) == 10);
34     assert(countn<10>({a}) == 10);
35     return true;
36 }
37 
main(int,char **)38 int main(int, char**) {
39     test();
40     static_assert(test());
41 
42     return 0;
43 }
44