8eb3da4e78095f198efb5ab16aa6a3efb9b86bc5
[platform/upstream/gcc48.git] / libstdc++-v3 / testsuite / 23_containers / list / operations / 2.h
1 // Copyright (C) 2001, 2004, 2005, 2009 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library.  This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
8
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without Pred the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3.  If not see
16 // <http://www.gnu.org/licenses/>.
17
18 // 23.2.2.4 list operations [lib.list.ops]
19
20 #include <testsuite_hooks.h>
21
22 // splice(p, x, i) + remove_if + operator==
23 template<typename _Tp>
24 void
25 operations02()
26 {
27   bool test __attribute__((unused)) = true;
28   typedef _Tp list_type;
29   typedef typename list_type::iterator iterator;
30
31   const int A[] = {1, 2, 3, 4, 5};
32   const int B[] = {2, 1, 3, 4, 5};
33   const int C[] = {1, 3, 4, 5, 2};
34   const int N = sizeof(A) / sizeof(int);
35   list_type list0201(A, A + N);
36   list_type list0202(A, A + N);
37   list_type list0203(B, B + N);
38   list_type list0204(C, C + N);
39   iterator i = list0201.begin();
40
41   // result should be unchanged
42   list0201.splice(list0201.begin(), list0201, i);
43   VERIFY(list0201 == list0202);
44
45   // result should be [2 1 3 4 5]
46   ++i;
47   list0201.splice(list0201.begin(), list0201, i);
48   VERIFY(list0201 != list0202);
49   VERIFY(list0201 == list0203);
50
51   // result should be [1 3 4 5 2]
52   list0201.splice(list0201.end(), list0201, i);
53   VERIFY(list0201 == list0204);
54 }