1*a8cf78c7SLouis Dionne //===----------------------------------------------------------------------===//
2*a8cf78c7SLouis Dionne //
3*a8cf78c7SLouis Dionne // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*a8cf78c7SLouis Dionne // See https://llvm.org/LICENSE.txt for license information.
5*a8cf78c7SLouis Dionne // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*a8cf78c7SLouis Dionne //
7*a8cf78c7SLouis Dionne //===----------------------------------------------------------------------===//
8*a8cf78c7SLouis Dionne // UNSUPPORTED: c++03, c++11, c++14, c++17
9*a8cf78c7SLouis Dionne 
10*a8cf78c7SLouis Dionne // <span>
11*a8cf78c7SLouis Dionne 
12*a8cf78c7SLouis Dionne // template <class ElementType, size_t Extent>
13*a8cf78c7SLouis Dionne //     span<byte,
14*a8cf78c7SLouis Dionne //          Extent == dynamic_extent
15*a8cf78c7SLouis Dionne //              ? dynamic_extent
16*a8cf78c7SLouis Dionne //              : sizeof(ElementType) * Extent>
17*a8cf78c7SLouis Dionne //     as_writable_bytes(span<ElementType, Extent> s) noexcept;
18*a8cf78c7SLouis Dionne 
19*a8cf78c7SLouis Dionne #include <span>
20*a8cf78c7SLouis Dionne #include <string>
21*a8cf78c7SLouis Dionne 
22*a8cf78c7SLouis Dionne #include "test_macros.h"
23*a8cf78c7SLouis Dionne 
24*a8cf78c7SLouis Dionne const int iArr2[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
25*a8cf78c7SLouis Dionne 
26*a8cf78c7SLouis Dionne struct A {};
27*a8cf78c7SLouis Dionne 
f()28*a8cf78c7SLouis Dionne void f() {
29*a8cf78c7SLouis Dionne   std::as_writable_bytes(std::span<const int>());            // expected-error {{no matching function for call to 'as_writable_bytes'}}
30*a8cf78c7SLouis Dionne   std::as_writable_bytes(std::span<const long>());           // expected-error {{no matching function for call to 'as_writable_bytes'}}
31*a8cf78c7SLouis Dionne   std::as_writable_bytes(std::span<const double>());         // expected-error {{no matching function for call to 'as_writable_bytes'}}
32*a8cf78c7SLouis Dionne   std::as_writable_bytes(std::span<const A>());              // expected-error {{no matching function for call to 'as_writable_bytes'}}
33*a8cf78c7SLouis Dionne   std::as_writable_bytes(std::span<const std::string>());    // expected-error {{no matching function for call to 'as_writable_bytes'}}
34*a8cf78c7SLouis Dionne 
35*a8cf78c7SLouis Dionne   std::as_writable_bytes(std::span<const int, 0>());         // expected-error {{no matching function for call to 'as_writable_bytes'}}
36*a8cf78c7SLouis Dionne   std::as_writable_bytes(std::span<const long, 0>());        // expected-error {{no matching function for call to 'as_writable_bytes'}}
37*a8cf78c7SLouis Dionne   std::as_writable_bytes(std::span<const double, 0>());      // expected-error {{no matching function for call to 'as_writable_bytes'}}
38*a8cf78c7SLouis Dionne   std::as_writable_bytes(std::span<const A, 0>());           // expected-error {{no matching function for call to 'as_writable_bytes'}}
39*a8cf78c7SLouis Dionne   std::as_writable_bytes(std::span<const std::string, (size_t)0>()); // expected-error {{no matching function for call to 'as_writable_bytes'}}
40*a8cf78c7SLouis Dionne 
41*a8cf78c7SLouis Dionne   std::as_writable_bytes(std::span<const int>   (iArr2, 1));     // expected-error {{no matching function for call to 'as_writable_bytes'}}
42*a8cf78c7SLouis Dionne   std::as_writable_bytes(std::span<const int, 1>(iArr2 + 5, 1)); // expected-error {{no matching function for call to 'as_writable_bytes'}}
43*a8cf78c7SLouis Dionne }
44