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

source code of libcxx/test/std/ranges/range.factories/range.single.view/ctor.in_place.pass.cpp