]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/set/modifiers/dr130.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / set / modifiers / dr130.cc
CommitLineData
52066eae 1// { dg-do run { target c++11 } }
c105751c
ESR
2// 2008-07-22 Edward Smith-Rowland <3dw4rd@verizon.net>
3//
8d9254fc 4// Copyright (C) 2009-2020 Free Software Foundation, Inc.
c105751c
ESR
5//
6// This file is part of the GNU ISO C++ Library. This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
9// Free Software Foundation; either version 3, or (at your option)
10// any later version.
11//
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License along
18// with this library; see the file COPYING3. If not see
19// <http://www.gnu.org/licenses/>.
20
21#include <set>
22#include <testsuite_hooks.h>
23
24// DR 130. Associative erase should return an iterator.
25void
26test01()
27{
c105751c
ESR
28 using namespace std;
29
30 set<int> s0;
31 typedef set<int>::iterator iterator;
32 typedef set<int>::const_iterator const_iterator;
33 typedef pair<iterator, bool> insert_return_type;
34
567d4027 35 s0.insert(1);
c105751c
ESR
36 insert_return_type irt1 = s0.insert(2);
37 insert_return_type irt2 = s0.insert(3);
38
39 iterator pos1 = s0.erase(irt1.first);
40 VERIFY( pos1 == irt2.first );
41
42 iterator pos2 = s0.erase(irt2.first);
43 VERIFY( pos2 == s0.end() );
44}
45
46void
47test02()
48{
c105751c
ESR
49 using namespace std;
50
51 set<int> s0;
52 typedef set<int>::iterator iterator;
53 typedef set<int>::const_iterator const_iterator;
54 typedef pair<iterator, bool> insert_return_type;
55
56 insert_return_type irt0 = s0.insert(1);
567d4027 57 s0.insert(2);
c105751c
ESR
58 insert_return_type irt2 = s0.insert(3);
59 insert_return_type irt3 = s0.insert(4);
60
61 iterator pos1 = s0.erase(irt0.first, irt2.first);
62 VERIFY( pos1 == irt2.first );
63
64 iterator pos2 = s0.erase(irt2.first, ++irt3.first);
65 VERIFY( pos2 == s0.end() );
66}
67
68int
69main()
70{
71 test01();
72 test02();
73}