]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/23_containers/forward_list/modifiers/2.cc
1 // { dg-options "-std=gnu++11" }
3 // Copyright (C) 2008-2015 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 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even 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 COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // 23.2.3.n forward_list xxx [lib.forward_list.xxx]
22 #include <forward_list>
23 #include <testsuite_hooks.h>
27 bool test
__attribute__((unused
)) = true;
29 // This test verifies the following:
30 // insert_after single item
31 // before_begin iterator
35 std::forward_list
<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
37 std::forward_list
<int>::iterator ret
= fl
.insert_after(fl
.before_begin(),
39 VERIFY( ret
== fl
.begin() );
40 VERIFY( fl
.front() == 42 );
43 // This test verifies the following:
47 std::forward_list
<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
49 std::forward_list
<int>::const_iterator pos
= fl
.cbegin();
53 std::forward_list
<int>::iterator ret
= fl
.insert_after(pos
, 0, 42);
56 ret
= fl
.insert_after(pos
, 5, 42);
71 // This test verifies the following:
75 std::forward_list
<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
77 std::forward_list
<int>::const_iterator pos
= fl
.cbegin();
81 int i
[3] = {666, 777, 888};
82 std::forward_list
<int>::iterator ret
= fl
.insert_after(pos
, i
, i
);
85 ret
= fl
.insert_after(pos
, i
, i
+ 3);
91 VERIFY( *pos
== 888 );
97 // This test verifies the following:
101 std::forward_list
<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
103 std::forward_list
<int>::const_iterator pos
= fl
.cbegin();
107 std::forward_list
<int>::iterator ret
= fl
.insert_after(pos
, { });
110 ret
= fl
.insert_after(pos
, {-1, -2, -3, -4, -5});
116 VERIFY( *pos
== -3 );
119 VERIFY( ret
== pos
);
124 // This test verifies the following:
128 std::forward_list
<std::string
> fl({"AAA", "BBB", "CCC"});
130 std::forward_list
<std::string
>::const_iterator pos
= fl
.cbegin();
132 VERIFY( *pos
== "BBB" );
134 std::string
x( "XXX" );
135 std::forward_list
<std::string
>::iterator ret
136 = fl
.insert_after(pos
, std::move(x
));
137 VERIFY( *pos
== "BBB" );
139 VERIFY( ret
== pos
);
140 VERIFY( *pos
== "XXX" );
142 VERIFY( *pos
== "CCC" );