]>
Commit | Line | Data |
---|---|---|
b74318f1 BW |
1 | // Test for Container using non-standard pointer types. |
2 | ||
83ffe9cd | 3 | // Copyright (C) 2008-2023 Free Software Foundation, Inc. |
b74318f1 BW |
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 | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
b74318f1 BW |
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 | |
748086b7 JJ |
17 | // with this library; see the file COPYING3. If not see |
18 | // <http://www.gnu.org/licenses/>. | |
b74318f1 | 19 | |
b74318f1 BW |
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 | ||
31 | namespace 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 | ||
44 | int 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 | ||
0d04fe49 JW |
49 | (void) v[0]; |
50 | (void) w[0]; | |
51 | (void) v.size(); | |
52 | (void) v.capacity(); | |
b74318f1 BW |
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 | } |