1bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//===----------------------------------------------------------------------===//
2bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//
3f5256e16dfc425c1d466f6308d4026d529ce9e0bHoward Hinnant//                     The LLVM Compiler Infrastructure
4bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//
5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// This file is dual licensed under the MIT and the University of Illinois Open
6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// Source Licenses. See LICENSE.TXT for details.
7bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//
8bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//===----------------------------------------------------------------------===//
9bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
10bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// <algorithm>
11bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
12eb564e76cc3904d811c981a50ecce0659f444cc9Howard Hinnant// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter>
13bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//   OutIter
14bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//   copy_n(InIter first, InIter::difference_type n, OutIter result);
15bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
16bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <algorithm>
17bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <cassert>
18bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
1983e2c4d877fe2d7793868b1c6a5d9525a7c4d431Marshall Clow#include "test_iterators.h"
20bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
21bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnanttemplate <class InIter, class OutIter>
22bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantvoid
23bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnanttest()
24bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{
25bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    const unsigned N = 1000;
26bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    int ia[N];
27bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    for (unsigned i = 0; i < N; ++i)
28bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        ia[i] = i;
29bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    int ib[N] = {0};
30bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
31bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    OutIter r = std::copy_n(InIter(ia), N/2, OutIter(ib));
32bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    assert(base(r) == ib+N/2);
33bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    for (unsigned i = 0; i < N/2; ++i)
34bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant        assert(ia[i] == ib[i]);
35bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant}
36bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
37bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantint main()
38bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{
39bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<input_iterator<const int*>, output_iterator<int*> >();
40bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<input_iterator<const int*>, input_iterator<int*> >();
41bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<input_iterator<const int*>, forward_iterator<int*> >();
42bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
43bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<input_iterator<const int*>, random_access_iterator<int*> >();
44bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<input_iterator<const int*>, int*>();
45bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
46bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<forward_iterator<const int*>, output_iterator<int*> >();
47bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<forward_iterator<const int*>, input_iterator<int*> >();
48bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<forward_iterator<const int*>, forward_iterator<int*> >();
49bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
50bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<forward_iterator<const int*>, random_access_iterator<int*> >();
51bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<forward_iterator<const int*>, int*>();
52bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
53bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
54bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<bidirectional_iterator<const int*>, input_iterator<int*> >();
55bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
56bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
57bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
58bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<bidirectional_iterator<const int*>, int*>();
59bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
60bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<random_access_iterator<const int*>, output_iterator<int*> >();
61bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<random_access_iterator<const int*>, input_iterator<int*> >();
62bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<random_access_iterator<const int*>, forward_iterator<int*> >();
63bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
64bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
65bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<random_access_iterator<const int*>, int*>();
66bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant
67bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<const int*, output_iterator<int*> >();
68bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<const int*, input_iterator<int*> >();
69bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<const int*, forward_iterator<int*> >();
70bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<const int*, bidirectional_iterator<int*> >();
71bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<const int*, random_access_iterator<int*> >();
72bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant    test<const int*, int*>();
73bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant}
74