| 1 | // Copyright (C) 2011-2025 Free Software Foundation, Inc. |
| 2 | // |
| 3 | // This file is part of the GNU ISO C++ Library. This library is free |
| 4 | // software; you can redistribute it and/or modify it under the |
| 5 | // terms of the GNU General Public License as published by the |
| 6 | // Free Software Foundation; either version 3, or (at your option) |
| 7 | // any later version. |
| 8 | // |
| 9 | // This library is distributed in the hope that it will be useful, |
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | // GNU General Public License for more details. |
| 13 | // |
| 14 | // You should have received a copy of the GNU General Public License along |
| 15 | // with this library; see the file COPYING3. If not see |
| 16 | // <http://www.gnu.org/licenses/>. |
| 17 | // |
| 18 | // { dg-do compile { target c++11 } } |
| 19 | |
| 20 | #include <debug/vector> |
| 21 | #include <type_traits> |
| 22 | #include <testsuite_allocator.h> |
| 23 | |
| 24 | template<typename T, typename A> |
| 25 | void |
| 26 | test() |
| 27 | { |
| 28 | typedef std::vector<T, A> base; |
| 29 | typedef __gnu_debug::vector<T, A> debug; |
| 30 | |
| 31 | using std::is_nothrow_default_constructible; |
| 32 | using std::is_nothrow_copy_constructible; |
| 33 | using std::is_nothrow_move_constructible; |
| 34 | using std::is_nothrow_copy_assignable; |
| 35 | using std::is_nothrow_move_assignable; |
| 36 | |
| 37 | static_assert( |
| 38 | is_nothrow_default_constructible<base>::value |
| 39 | == is_nothrow_default_constructible<debug>::value, |
| 40 | "nothrow default constructible"); |
| 41 | |
| 42 | static_assert( |
| 43 | is_nothrow_copy_constructible<base>::value |
| 44 | == is_nothrow_copy_constructible<debug>::value, |
| 45 | "nothrow copy constructible"); |
| 46 | |
| 47 | static_assert( |
| 48 | is_nothrow_move_constructible<base>::value |
| 49 | == is_nothrow_move_constructible<debug>::value, |
| 50 | "nothrow move constructible"); |
| 51 | |
| 52 | static_assert( |
| 53 | is_nothrow_copy_assignable<base>::value |
| 54 | == is_nothrow_copy_assignable<debug>::value, |
| 55 | "nothrow move assignable"); |
| 56 | |
| 57 | static_assert( |
| 58 | is_nothrow_move_assignable<base>::value |
| 59 | == is_nothrow_move_assignable<debug>::value, |
| 60 | "nothrow move assignable"); |
| 61 | } |
| 62 | |
| 63 | struct X |
| 64 | { |
| 65 | X() { } |
| 66 | ~X() { } |
| 67 | X(const X&) { } |
| 68 | X(X&&) { } |
| 69 | X& operator=(const X&) { return *this; } |
| 70 | X& operator=(X&&) { return *this; } |
| 71 | }; |
| 72 | |
| 73 | int main() |
| 74 | { |
| 75 | using __gnu_test::propagating_allocator; |
| 76 | using __gnu_test::SimpleAllocator; |
| 77 | |
| 78 | test<int, std::allocator<int>>(); |
| 79 | test<int, SimpleAllocator<int>>(); |
| 80 | test<int, propagating_allocator<int, true>>(); |
| 81 | test<int, propagating_allocator<int, false>>(); |
| 82 | test<X, std::allocator<X>>(); |
| 83 | test<X, SimpleAllocator<X>>(); |
| 84 | test<X, propagating_allocator<X, true>>(); |
| 85 | test<X, propagating_allocator<X, false>>(); |
| 86 | |
| 87 | return 0; |
| 88 | } |