]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/vector/debug_mode_requires_reallocation-2.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / vector / debug_mode_requires_reallocation-2.cc
CommitLineData
85ec4feb 1// Copyright (C) 2008-2018 Free Software Foundation, Inc.
36d6d979
RB
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
748086b7 6// Free Software Foundation; either version 3, or (at your option)
36d6d979
RB
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even 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
748086b7
JJ
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
36d6d979 17
ab1c1187
PC
18// NB: This issue affected only debug-mode, in pedantic mode.
19
20// { dg-options "-D_GLIBCXX_DEBUG_PEDANTIC" }
36d6d979
RB
21
22#include <vector>
23#include <algorithm>
24#include <iterator>
25
2028b66d 26// http://gcc.gnu.org/ml/libstdc++/2008-05/msg00046.html
36d6d979
RB
27void test01()
28{
29 typedef std::vector<unsigned> array_t;
30 typedef std::back_insert_iterator<array_t> bii_t;
31
32 array_t a;
33
34 // Push 5 elements.
35 a.push_back(0);
36 a.push_back(1);
37 a.push_back(2);
38 a.push_back(3);
39 a.push_back(4);
40 // Ensure that there is enough space for other two elements.
41 // (2 + 5 = 7)
42 if (a.capacity() < 7)
43 a.reserve(7);
44 // Add two new elements.
45 std::copy(a.begin(), a.begin() + 2, bii_t(a));
46}
47
48int main()
49{
50 test01();
51 return 0;
52}