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 | |
9 | // UNSUPPORTED: c++03, c++11, c++14, c++17 |
10 | |
11 | // <span> |
12 | |
13 | // constexpr explicit(extent != dynamic_extent) span(std::initializer_list<value_type> il); // Since C++26 |
14 | |
15 | #include <span> |
16 | #include <utility> |
17 | |
18 | #include "test_macros.h" |
19 | |
20 | // Test P2447R4 "Annex C examples" |
21 | |
22 | void one(std::pair<int, int>); |
23 | void one(std::span<const int>); |
24 | |
25 | void two(std::span<const int, 2>); |
26 | |
27 | void test_P2447R4_annex_c_examples() { |
28 | // 1. Overload resolution is affected |
29 | #if TEST_STD_VER >= 26 |
30 | // expected-error@+1 {{call to 'one' is ambiguous}} |
31 | one({1, 2}); |
32 | #else |
33 | // expected-no-diagnostics |
34 | one({1, 2}); |
35 | #endif |
36 | |
37 | // 2. The `initializer_list` ctor has high precedence |
38 | #if TEST_STD_VER >= 26 |
39 | // expected-error@+1 {{chosen constructor is explicit in copy-initialization}} |
40 | two({{1, 2}}); |
41 | #else |
42 | // expected-no-diagnostics |
43 | two({{1, 2}}); |
44 | #endif |
45 | |
46 | // 3. Implicit two-argument construction with a highly convertible value_type |
47 | // --> tested in "initializer_list.pass.cpp" |
48 | } |
49 | |