1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <forward_list>
11 
12 // template <class Compare> void merge(forward_list&& x, Compare comp);
13 
14 #include <forward_list>
15 #include <iterator>
16 #include <functional>
17 #include <cassert>
18 
19 #include "min_allocator.h"
20 
main()21 int main()
22 {
23     {
24         typedef int T;
25         typedef std::forward_list<T> C;
26         const T t1[] = {13, 12, 7, 6, 5, 3};
27         const T t2[] = {15, 14, 11, 10, 9, 8, 4, 2, 1, 0};
28         const T t3[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
29         C c1(std::begin(t1), std::end(t1));
30         C c2(std::begin(t2), std::end(t2));
31         c1.merge(c2, std::greater<T>());
32         C c3(std::begin(t3), std::end(t3));
33         assert(c1 == c3);
34     }
35 #if __cplusplus >= 201103L
36     {
37         typedef int T;
38         typedef std::forward_list<T, min_allocator<T>> C;
39         const T t1[] = {13, 12, 7, 6, 5, 3};
40         const T t2[] = {15, 14, 11, 10, 9, 8, 4, 2, 1, 0};
41         const T t3[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
42         C c1(std::begin(t1), std::end(t1));
43         C c2(std::begin(t2), std::end(t2));
44         c1.merge(c2, std::greater<T>());
45         C c3(std::begin(t3), std::end(t3));
46         assert(c1 == c3);
47     }
48 #endif
49 }
50