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 #include <algorithm>
12 #include <cassert>
13 #include <concepts>
14 #include <deque>
15 #include <vector>
16 
17 template <class InContainer, class OutContainer>
18 constexpr void test_containers() {
19   using InIter  = typename InContainer::iterator;
20   using OutIter = typename OutContainer::iterator;
21 
22   {
23     InContainer in{1, 2, 3, 4};
24     OutContainer out(4);
25 
26     std::same_as<std::ranges::in_out_result<InIter, OutIter>> auto ret =
27         std::ranges::copy(in.begin(), in.end(), out.begin());
28     assert(std::ranges::equal(in, out));
29     assert(ret.in == in.end());
30     assert(ret.out == out.end());
31   }
32   {
33     InContainer in{1, 2, 3, 4};
34     OutContainer out(4);
35     std::same_as<std::ranges::in_out_result<InIter, OutIter>> auto ret = std::ranges::copy(in, out.begin());
36     assert(std::ranges::equal(in, out));
37     assert(ret.in == in.end());
38     assert(ret.out == out.end());
39   }
40 }
41 
42 int main(int, char**) {
43   if (!std::is_constant_evaluated()) {
44     test_containers<std::deque<int>, std::deque<int>>();
45     test_containers<std::deque<int>, std::vector<int>>();
46     test_containers<std::vector<int>, std::deque<int>>();
47     test_containers<std::vector<int>, std::vector<int>>();
48   }
49 
50   return 0;
51 }
52