1 // { dg-options "-std=gnu++0x" }
3 // Copyright (C) 2008 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without Pred the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // 23.2.3.n forward_list xxx [lib.forward_list.xxx]
23 #include <forward_list>
24 #include <ext/extptr_allocator.h>
25 #include <testsuite_hooks.h>
29 bool test __attribute__((unused)) = true;
31 using __gnu_cxx::_ExtPtr_allocator;
33 // This test verifies the following:
34 // insert_after single item
35 // before_begin iterator
39 std::forward_list<int, _ExtPtr_allocator<int> > fl(
40 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
42 fl.insert_after(fl.before_begin(), 42);
43 VERIFY(fl.front() == 42);
46 // This test verifies the following:
50 std::forward_list<int, _ExtPtr_allocator<int> > fl(
51 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
53 std::forward_list<int, _ExtPtr_allocator<int> >::const_iterator
59 // Note: Calling l.insert_after(pos, 5, 42); without the long five
60 // gets resolved to the iterator range version and fails to compile!
61 fl.insert_after(pos, 5, 42);
73 // This test verifies the following:
77 std::forward_list<int, _ExtPtr_allocator<int> > fl(
78 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
80 std::forward_list<int, _ExtPtr_allocator<int> >::const_iterator
86 int i[3] = {666, 777, 888};
87 fl.insert_after(pos, i, i+3);
98 // This test verifies the following:
102 std::forward_list<int, _ExtPtr_allocator<int> > fl(
103 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
105 std::forward_list<int, _ExtPtr_allocator<int> >::const_iterator
111 fl.insert_after(pos, {-1, -2, -3, -4, -5});
120 // This test verifies the following:
124 std::forward_list<std::string, _ExtPtr_allocator<std::string> > fl(
125 {"AAA", "BBB", "CCC"});
127 std::forward_list<std::string, _ExtPtr_allocator<std::string> >::const_iterator
131 VERIFY(*pos == "BBB");
133 std::string x( "XXX" );
134 fl.insert_after(pos, std::move(x));
135 VERIFY(*pos == "BBB");
137 VERIFY(*pos == "XXX");
139 VERIFY(*pos == "CCC");