]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/2.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / vector / ext_pointer / types / 2.cc
CommitLineData
c51b58dc
JW
1// Test for Container using non-standard pointer types.
2
8d9254fc 3// Copyright (C) 2011-2020 Free Software Foundation, Inc.
c51b58dc
JW
4//
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)
9// any later version.
10
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.
15
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/>.
19
20
52066eae 21// { dg-do run { target c++11 } }
c51b58dc
JW
22
23// This is a copy of vector/types/1.cc with altered allocator.
24// The operator+()s in this test initially failed the test -
25// they stress the accurate recognition, by the compiler,
26// of _Pointer_adapter's own pointer arithmetic functions,
27// which have to match perfectly on the int type to get
28// chosen by the compiler when it sees: _Pointer_adapter<T> + int, etc.
29
30#include <vector>
31#include <ext/extptr_allocator.h>
32
33namespace N
34{
35 struct X { };
36
37 template<typename T>
38 X operator+(T, std::size_t)
39 { return X(); }
40
41 template<typename T>
42 X operator-(T, T)
43 { return X(); }
44}
45
46int main()
47{
48 std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > v(5);
49 const std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > w(1);
50
51 v[0];
52 w[0];
53 v.size();
54 v.capacity();
55 v.resize(1);
56 v.insert(v.begin(), N::X());
57 v.insert(v.begin(), 1, N::X());
58 v.insert(v.begin(), w.begin(), w.end());
59 v = w;
60
61 return 0;
62}