Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <vector> |
| 11 | // vector<bool> |
| 12 | |
| 13 | // vector(const Alloc& = Alloc()); |
| 14 | |
| 15 | #include <vector> |
| 16 | #include <cassert> |
| 17 | |
Marshall Clow | 127db91 | 2015-06-04 00:10:20 +0000 | [diff] [blame] | 18 | #include "test_macros.h" |
Marshall Clow | 1b92188 | 2013-12-03 00:18:10 +0000 | [diff] [blame] | 19 | #include "test_allocator.h" |
Marshall Clow | 061d0cc | 2013-11-26 20:58:02 +0000 | [diff] [blame] | 20 | #include "min_allocator.h" |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 21 | |
| 22 | template <class C> |
| 23 | void |
| 24 | test0() |
| 25 | { |
Marshall Clow | 127db91 | 2015-06-04 00:10:20 +0000 | [diff] [blame] | 26 | #if TEST_STD_VER > 14 |
| 27 | static_assert((noexcept(C{})), "" ); |
| 28 | #elif TEST_STD_VER >= 11 |
| 29 | static_assert((noexcept(C()) == noexcept(typename C::allocator_type())), "" ); |
| 30 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 31 | C c; |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 32 | assert(c.__invariants()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 33 | assert(c.empty()); |
| 34 | assert(c.get_allocator() == typename C::allocator_type()); |
Marshall Clow | 127db91 | 2015-06-04 00:10:20 +0000 | [diff] [blame] | 35 | #if TEST_STD_VER >= 11 |
Marshall Clow | 48c7470 | 2014-03-05 19:06:20 +0000 | [diff] [blame] | 36 | C c1 = {}; |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 37 | assert(c1.__invariants()); |
Marshall Clow | 48c7470 | 2014-03-05 19:06:20 +0000 | [diff] [blame] | 38 | assert(c1.empty()); |
| 39 | assert(c1.get_allocator() == typename C::allocator_type()); |
| 40 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | template <class C> |
| 44 | void |
| 45 | test1(const typename C::allocator_type& a) |
| 46 | { |
Marshall Clow | 127db91 | 2015-06-04 00:10:20 +0000 | [diff] [blame] | 47 | #if TEST_STD_VER > 14 |
| 48 | static_assert((noexcept(C{typename C::allocator_type{}})), "" ); |
| 49 | #elif TEST_STD_VER >= 11 |
| 50 | static_assert((noexcept(C(typename C::allocator_type())) == std::is_nothrow_copy_constructible<typename C::allocator_type>::value), "" ); |
| 51 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 52 | C c(a); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 53 | assert(c.__invariants()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 54 | assert(c.empty()); |
| 55 | assert(c.get_allocator() == a); |
| 56 | } |
| 57 | |
| 58 | int main() |
| 59 | { |
| 60 | { |
| 61 | test0<std::vector<bool> >(); |
| 62 | test1<std::vector<bool, test_allocator<bool> > >(test_allocator<bool>(3)); |
| 63 | } |
Marshall Clow | 127db91 | 2015-06-04 00:10:20 +0000 | [diff] [blame] | 64 | #if TEST_STD_VER >= 11 |
Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 +0000 | [diff] [blame] | 65 | { |
| 66 | test0<std::vector<bool, min_allocator<bool>> >(); |
| 67 | test1<std::vector<bool, min_allocator<bool> > >(min_allocator<bool>()); |
| 68 | } |
| 69 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 70 | } |