1// { dg-options "-std=gnu++11" } 2// 3// Copyright (C) 2013-2015 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. 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 25template<typename T> 26struct 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. 35template<typename T> 36struct 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 52typedef alloc<int> alloc_type; 53typedef std::allocator_traits<alloc_type> traits; 54 55using std::is_same; 56 57static_assert( is_same<traits::pointer, alloc_type::pointer>::value, 58 "pointer" ); 59 60static_assert( is_same<traits::const_pointer, 61 alloc_type::const_pointer>::value, 62 "const_pointer" ); 63 64static_assert( is_same<traits::void_pointer, alloc_type::void_pointer>::value, 65 "void_pointer" ); 66 67static_assert( is_same<traits::const_void_pointer, 68 alloc_type::const_void_pointer>::value, 69 "const_void_pointer"); 70 71static_assert( is_same<traits::difference_type, 72 alloc_type::difference_type>::value, 73 "difference_type" ); 74 75static_assert( is_same<traits::size_type, alloc_type::size_type>::value, 76 "size_type" ); 77 78static_assert( is_same<traits::size_type, alloc_type::size_type>::value, 79 "size_type" ); 80 81static_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 86static_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 91static_assert( is_same<traits::propagate_on_container_swap, 92 alloc_type::propagate_on_container_swap>::value, 93 "propagate_on_container_swap" ); 94