diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-10-31 20:49:40 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-10-31 20:49:40 +0000 |
commit | 081db185ef94b45c72106e3725fe64de56b402d2 (patch) | |
tree | b2e6ecad35b86d5807204670bcf8e10569378ee0 /libstdc++-v3/testsuite/23_containers/vector/bool/allocator/noexcept.cc | |
parent | 978e3209f5105a855fff642a0c5487713bab8a23 (diff) | |
download | gcc-081db185ef94b45c72106e3725fe64de56b402d2.tar.gz |
Make std::vector<bool> meet C++11 allocator requirements.
* include/bits/stl_bvector.h (_Bvector_base): Use allocator_traits.
(_Bvector_base::_Bvector_impl): Use allocator's pointer type.
(_Bvector_base::_M_end_addr()): Convert to raw pointer.
(vector<bool>): Use allocator_traits and _M_end_addr. Add allocator
extended constructors.
* include/bits/vector.tcc (vector<bool>): Use allocator_traits and
_M_end_addr.
* testsuite/23_containers/vector/bool/allocator/copy.cc: New.
* testsuite/23_containers/vector/bool/allocator/minimal.cc: New.
* testsuite/23_containers/vector/bool/allocator/noexcept.cc: New.
* testsuite/23_containers/vector/bool/allocator/copy_assign.cc: New.
* testsuite/23_containers/vector/bool/allocator/move.cc: New.
* testsuite/23_containers/vector/bool/allocator/swap.cc: New.
* testsuite/23_containers/vector/bool/allocator/ext_ptr.cc: New.
* testsuite/23_containers/vector/bool/allocator/move_assign.cc: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@216988 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers/vector/bool/allocator/noexcept.cc')
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/vector/bool/allocator/noexcept.cc | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/noexcept.cc new file mode 100644 index 00000000000..e86e6b205b8 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/noexcept.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2014 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-do compile } +// { dg-options "-std=gnu++11" } + +#include <vector> +#include <testsuite_allocator.h> + +using T = bool; + +namespace __gnu_test +{ + template<typename U> + inline void + swap(propagating_allocator<U, true>& l, propagating_allocator<U, true>& r) + noexcept(false) + { } +} + +using __gnu_test::propagating_allocator; + +void test01() +{ + typedef std::allocator<T> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1; + test_type v2; + // this is a GNU extension for std::allocator + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test02() +{ + typedef propagating_allocator<T, false> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( !noexcept( v1 = std::move(v2) ), "Move assign can throw" ); + static_assert( noexcept( v1.swap(v2) ), "Swap cannot throw" ); +} + +void test03() +{ + typedef propagating_allocator<T, true> alloc_type; + typedef std::vector<T, alloc_type> test_type; + test_type v1(alloc_type(1)); + test_type v2(alloc_type(2)); + static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); +} |