diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-06-16 17:13:34 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-06-16 17:13:34 +0000 |
commit | a6135b896a99613d340fccfce5b75c3ee877b951 (patch) | |
tree | a787782bbdf54370a295ec8cc411fa7005308b66 /libstdc++-v3/testsuite/23_containers | |
parent | 57db98e1a3c83df78f4a5a877ddef55bb046d6fd (diff) | |
download | gcc-a6135b896a99613d340fccfce5b75c3ee877b951.tar.gz |
PR libstdc++/57263
* include/bits/forward_list.h (_Fwd_list_base): Convert to/from
allocator's pointer type.
* include/bits/hashtable.h (_Hashtable): Likewise.
* testsuite/util/testsuite_allocator.h (CustomPointerAlloc): Add.
* testsuite/23_containers/forward_list/allocator/ext_ptr.cc: New.
* testsuite/23_containers/unordered_set/allocator/ext_ptr.cc: New.
* testsuite/23_containers/vector/allocator/ext_ptr.cc: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200136 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers')
3 files changed, 138 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/allocator/ext_ptr.cc b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/ext_ptr.cc new file mode 100644 index 00000000000..6f3a0ed75dc --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/ext_ptr.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <forward_list> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; +bool operator==(const T& l, const T& r) { return l.i == r.i; } +bool operator<(const T& l, const T& r) { return l.i < r.i; } + +using __gnu_test::CustomPointerAlloc; + +template class std::forward_list<T, CustomPointerAlloc<T>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef CustomPointerAlloc<T> alloc_type; + typedef std::forward_list<T, alloc_type> test_type; + test_type v; + v.push_front(T()); + VERIFY( ++v.begin() == v.end() ); +} + +int main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/ext_ptr.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/ext_ptr.cc new file mode 100644 index 00000000000..55d9af3a5cb --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/ext_ptr.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <unordered_set> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; +bool operator==(const T& l, const T& r) { return l.i == r.i; } +struct H { std::size_t operator()(const T& t) const noexcept { return t.i; } +}; +struct E : std::equal_to<T> { }; + +using __gnu_test::CustomPointerAlloc; + +template class std::unordered_set<T, H, E, CustomPointerAlloc<T>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef CustomPointerAlloc<T> alloc_type; + typedef std::unordered_set<T, H, E, alloc_type> test_type; + test_type v; + v.insert(T()); + VERIFY( ++v.begin() == v.end() ); +} + +int main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/allocator/ext_ptr.cc b/libstdc++-v3/testsuite/23_containers/vector/allocator/ext_ptr.cc new file mode 100644 index 00000000000..b94a47a939b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/allocator/ext_ptr.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <vector> +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +struct T { int i; }; + +using __gnu_test::CustomPointerAlloc; + +template class std::vector<T, CustomPointerAlloc<T>>; + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef CustomPointerAlloc<T> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v; + v.push_back(T()); + VERIFY( ++v.begin() == v.end() ); +} + +int main() +{ + test01(); +} |