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-has-no-incomplete-ranges
11 
12 // template<class... Args>
13 //   requires constructible_from<T, Args...>
14 // constexpr explicit single_view(in_place_t, Args&&... args);
15 
16 #include <cassert>
17 #include <ranges>
18 #include <utility>
19 
20 #include "test_macros.h"
21 
22 struct TakesTwoInts {
23   int a_, b_;
TakesTwoIntsTakesTwoInts24   constexpr TakesTwoInts(int a, int b) : a_(a), b_(b) {}
25 };
26 
test()27 constexpr bool test() {
28   {
29     std::ranges::single_view<TakesTwoInts> sv(std::in_place, 1, 2);
30     assert(sv.data()->a_ == 1);
31     assert(sv.data()->b_ == 2);
32     assert(sv.size() == 1);
33   }
34   {
35     const std::ranges::single_view<TakesTwoInts> sv(std::in_place, 1, 2);
36     assert(sv.data()->a_ == 1);
37     assert(sv.data()->b_ == 2);
38     assert(sv.size() == 1);
39   }
40 
41   return true;
42 }
43 
main(int,char **)44 int main(int, char**) {
45   test();
46   static_assert(test());
47 
48   return 0;
49 }
50