1// Test for Container using non-standard pointer types. 2 3// Copyright (C) 2008, 2009 4// Free Software Foundation, Inc. 5// 6// This file is part of the GNU ISO C++ Library. This library is free 7// software; you can redistribute it and/or modify it under the 8// terms of the GNU General Public License as published by the 9// Free Software Foundation; either version 3, or (at your option) 10// any later version. 11 12// This library is distributed in the hope that it will be useful, 13// but WITHOUT ANY WARRANTY; without even the implied warranty of 14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15// GNU General Public License for more details. 16 17// You should have received a copy of the GNU General Public License along 18// with this library; see the file COPYING3. If not see 19// <http://www.gnu.org/licenses/>. 20 21 22// This is a copy of vector/types/1.cc with altered allocator. 23// The operator+()s in this test initially failed the test - 24// they stress the accurate recognition, by the compiler, 25// of _Pointer_adapter's own pointer arithmetic functions, 26// which have to match perfectly on the int type to get 27// chosen by the compiler when it sees: _Pointer_adapter<T> + int, etc. 28 29#include <vector> 30#include <ext/extptr_allocator.h> 31 32namespace N 33{ 34 struct X { }; 35 36 template<typename T> 37 X operator+(T, std::size_t) 38 { return X(); } 39 40 template<typename T> 41 X operator-(T, T) 42 { return X(); } 43} 44 45int main() 46{ 47 std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > v(5); 48 const std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > w(1); 49 50 v[0]; 51 w[0]; 52 v.size(); 53 v.capacity(); 54 v.resize(1); 55 v.insert(v.begin(), N::X()); 56 v.insert(v.begin(), 1, N::X()); 57 v.insert(v.begin(), w.begin(), w.end()); 58 v = w; 59 60 return 0; 61} 62