]>
Commit | Line | Data |
---|---|---|
20067423 JW |
1 | // { dg-options "-std=gnu++11" } |
2 | // | |
818ab71a | 3 | // Copyright (C) 2013-2016 Free Software Foundation, Inc. |
20067423 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 | #include <memory> | |
21 | #include <testsuite_allocator.h> | |
22 | ||
23 | // { dg-do compile } | |
24 | ||
25 | template<typename T> | |
26 | struct ptr | |
27 | { | |
28 | ptr() = default; | |
29 | template<typename U> | |
30 | ptr(ptr<U> const& p) { } | |
31 | }; | |
32 | ||
33 | // This doesn't meet the allocator requirements, it's only to check | |
34 | // that allocator_traits finds the right nested types. | |
35 | template<typename T> | |
36 | struct alloc | |
37 | { | |
38 | typedef T value_type; | |
39 | ||
40 | typedef ptr<T> pointer; | |
41 | typedef ptr<const T> const_pointer; | |
42 | typedef ptr<void> void_pointer; | |
43 | typedef ptr<const void> const_void_pointer; | |
44 | typedef int difference_type; | |
45 | typedef int size_type; | |
46 | ||
47 | typedef std::false_type propagate_on_container_copy_assignment; | |
48 | typedef std::false_type propagate_on_container_move_assignment; | |
49 | typedef std::false_type propagate_on_container_swap; | |
50 | }; | |
51 | ||
52 | typedef alloc<int> alloc_type; | |
53 | typedef std::allocator_traits<alloc_type> traits; | |
54 | ||
55 | using std::is_same; | |
56 | ||
57 | static_assert( is_same<traits::pointer, alloc_type::pointer>::value, | |
58 | "pointer" ); | |
59 | ||
60 | static_assert( is_same<traits::const_pointer, | |
61 | alloc_type::const_pointer>::value, | |
62 | "const_pointer" ); | |
63 | ||
64 | static_assert( is_same<traits::void_pointer, alloc_type::void_pointer>::value, | |
65 | "void_pointer" ); | |
66 | ||
67 | static_assert( is_same<traits::const_void_pointer, | |
68 | alloc_type::const_void_pointer>::value, | |
69 | "const_void_pointer"); | |
70 | ||
71 | static_assert( is_same<traits::difference_type, | |
72 | alloc_type::difference_type>::value, | |
73 | "difference_type" ); | |
74 | ||
75 | static_assert( is_same<traits::size_type, alloc_type::size_type>::value, | |
76 | "size_type" ); | |
77 | ||
78 | static_assert( is_same<traits::size_type, alloc_type::size_type>::value, | |
79 | "size_type" ); | |
80 | ||
81 | static_assert( is_same<traits::propagate_on_container_copy_assignment, | |
82 | alloc_type::propagate_on_container_copy_assignment | |
83 | >::value, | |
84 | "propagate_on_container_copy_assignment" ); | |
85 | ||
86 | static_assert( is_same<traits::propagate_on_container_move_assignment, | |
87 | alloc_type::propagate_on_container_move_assignment | |
88 | >::value, | |
89 | "propagate_on_container_move_assignment" ); | |
90 | ||
91 | static_assert( is_same<traits::propagate_on_container_swap, | |
92 | alloc_type::propagate_on_container_swap>::value, | |
93 | "propagate_on_container_swap" ); |