OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [23_containers/] [vector/] [debug_mode_requires_reallocation-2.cc] - Blame information for rev 742

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// Copyright (C) 2008, 2009, 2010 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 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
15
// with this library; see the file COPYING3.  If not see
16
// <http://www.gnu.org/licenses/>.
17
 
18
// NB: This issue affected only debug-mode, in pedantic mode.
19
 
20
// { dg-options "-D_GLIBCXX_DEBUG_PEDANTIC" }
21
 
22
#include <vector>
23
#include <algorithm>
24
#include <iterator>
25
 
26
// http://gcc.gnu.org/ml/libstdc++/2008-05/msg00046.html
27
void 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
 
48
int main()
49
{
50
  test01();
51
  return 0;
52
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.