]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / vector / ext_pointer / types / 1.cc
CommitLineData
71736b76 1// Test for Container using non-standard pointer types.
2
fbd26352 3// Copyright (C) 2008-2019 Free Software Foundation, Inc.
71736b76 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
6bc9506f 8// Free Software Foundation; either version 3, or (at your option)
71736b76 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
6bc9506f 17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
71736b76 19
71736b76 20
21// This is a copy of vector/types/1.cc with altered allocator.
22// The operator+()s in this test initially failed the test -
23// they stress the accurate recognition, by the compiler,
24// of _Pointer_adapter's own pointer arithmetic functions,
25// which have to match perfectly on the int type to get
26// chosen by the compiler when it sees: _Pointer_adapter<T> + int, etc.
27
28#include <vector>
29#include <ext/extptr_allocator.h>
30
31namespace N
32{
33 struct X { };
34
35 template<typename T>
36 X operator+(T, std::size_t)
37 { return X(); }
38
39 template<typename T>
40 X operator-(T, T)
41 { return X(); }
42}
43
44int main()
45{
46 std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > v(5);
47 const std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > w(1);
48
49 v[0];
50 w[0];
51 v.size();
52 v.capacity();
53 v.resize(1);
54 v.insert(v.begin(), N::X());
55 v.insert(v.begin(), 1, N::X());
56 v.insert(v.begin(), w.begin(), w.end());
57 v = w;
58
59 return 0;
60}