Reverting merge from trunk
[official-gcc.git] / libstdc++-v3 / testsuite / 23_containers / map / 56613.cc
blob98433598c6be90291b0d3f59a45dbe9fc9121592
1 // -*- C++ -*-
3 // Copyright (C) 2013 Free Software Foundation, Inc.
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.
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.
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/>.
20 #include <testsuite_hooks.h>
21 #include <map>
23 // { dg-do compile }
24 // { dg-options "-std=gnu++11" }
26 // libstdc++/56613
27 #include <map>
29 // A conforming C++03 allocator, should still work in C++11 mode.
30 template<typename T>
31 struct alloc
33 typedef T value_type;
34 typedef T* pointer;
35 typedef const T* const_pointer;
36 typedef T& reference;
37 typedef const T& const_reference;
38 typedef unsigned size_type;
39 typedef int difference_type;
41 template<typename U>
42 struct rebind {
43 typedef alloc<U> other;
46 alloc() { }
47 template<typename U>
48 alloc(const alloc<U>&) { }
50 pointer allocate(size_type n, const void* = 0) { return
51 std::allocator<T>().allocate(n); }
52 void deallocate(pointer p, size_type n) { std::allocator<T>().deallocate(p,
53 n); }
55 size_type max_size() const { return -1; }
57 void construct(pointer p, const T& t) { new ((void*) p) T(t); }
58 void destroy(pointer p) { p->~T(); }
60 pointer address(reference x) const throw() { return &x; }
61 const_pointer address(const_reference x) const throw() { return &x; }
64 template<typename T, typename U>
65 bool operator==(alloc<T>, alloc<U>) { return true; }
67 template<typename T, typename U>
68 bool operator!=(alloc<T>, alloc<U>) { return false; }
70 int main()
72 std::map<int, int, std::less<int>, alloc<int> > m;
73 m[1];