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 // UNSUPPORTED: libcpp-no-concepts
11 // UNSUPPORTED: libcpp-has-no-incomplete-ranges
12 
13 // constexpr explicit single_view(const T& t);
14 // constexpr explicit single_view(T&& t);
15 
16 #include <ranges>
17 #include <cassert>
18 
19 #include "test_macros.h"
20 
21 struct Empty {};
22 struct BigType { char buffer[64] = {10}; };
23 
test()24 constexpr bool test() {
25   {
26     BigType bt;
27     std::ranges::single_view<BigType> sv(bt);
28     assert(sv.data()->buffer[0] == 10);
29     assert(sv.size() == 1);
30   }
31   {
32     const BigType bt;
33     const std::ranges::single_view<BigType> sv(bt);
34     assert(sv.data()->buffer[0] == 10);
35     assert(sv.size() == 1);
36   }
37 
38   {
39     BigType bt;
40     std::ranges::single_view<BigType> sv(std::move(bt));
41     assert(sv.data()->buffer[0] == 10);
42     assert(sv.size() == 1);
43   }
44   {
45     const BigType bt;
46     const std::ranges::single_view<BigType> sv(std::move(bt));
47     assert(sv.data()->buffer[0] == 10);
48     assert(sv.size() == 1);
49   }
50 
51   return true;
52 }
53 
main(int,char **)54 int main(int, char**) {
55   test();
56   static_assert(test());
57 
58   return 0;
59 }
60