Fortran: Fix PR 47485.
[gcc.git] / libstdc++-v3 / testsuite / 23_containers / vector / bool / cons / lwg3778.cc
blob49c510dd626bbf96a0f3d3a8dcd03ceacce72d2c
1 // { dg-do compile { target c++11 } }
3 // LWG 3778. vector<bool> missing exception specifications
5 #include <vector>
6 #include <testsuite_allocator.h>
8 using V = std::vector<bool>;
10 static_assert(std::is_nothrow_default_constructible<V>::value,
11 "nothrow default constructible with std::allocator");
12 static_assert(std::is_nothrow_constructible<V, V::allocator_type>::value,
13 "nothrow constructible with allocator argument");
14 static_assert(std::is_nothrow_move_constructible<V>::value,
15 "unconditionally nothrow move constructible");
16 static_assert(std::is_nothrow_move_assignable<V>::value,
17 "nothrow move assignment with std::allocator");
18 static_assert(std::__is_nothrow_swappable<V>::value,
19 "nothrow swap with std::allocator");
21 template<typename T>
22 struct Allocator : __gnu_test::SimpleAllocator<T>
24 Allocator() noexcept(false) { }
26 template<typename U>
27 Allocator(const Allocator<U>&) { }
30 using V2 = std::vector<bool, Allocator<bool>>;
31 static_assert(std::is_default_constructible<V2>::value,
32 "default constructible with Allocator<bool>");
33 static_assert(std::is_nothrow_constructible<V2, V2::allocator_type>::value,
34 "nothrow constructible with allocator argument");
35 static_assert(! std::is_nothrow_default_constructible<V2>::value,
36 "but not nothrow default constructible with Allocator<bool>");
37 static_assert(std::is_nothrow_move_constructible<V2>::value,
38 "also checked by ./noexcept_move_construct.cc");
39 static_assert(std::__is_nothrow_swappable<V>::value,
40 "nothrow swap with std::allocator");
42 template<typename T, typename IAE, typename POCMA = IAE>
43 struct PropAllocator : __gnu_test::SimpleAllocator<T>
45 PropAllocator() noexcept { }
47 template<typename U>
48 PropAllocator(const PropAllocator<U, IAE, POCMA>&) { }
50 using is_always_equal = POCMA;
51 using propagate_on_container_move_assignment = IAE;
54 using V3 = std::vector<bool, PropAllocator<bool, std::false_type>>;
55 static_assert(std::is_nothrow_move_constructible<V3>::value,
56 "unconditionally nothrow move constructible");
57 static_assert(std::is_nothrow_constructible<V3, V3::allocator_type>::value,
58 "nothrow constructible with allocator argument");
59 static_assert(! std::is_nothrow_move_assignable<V3>::value,
60 "throwing move assignment with !(propagating || equal) alloc");
61 #ifdef _GLIBCXX_RELEASE
62 // We strengthen std::vector<bool, A>::swap to be always noexcept.
63 static_assert(std::__is_nothrow_swappable<V3>::value,
64 "nothrow swap even with !(propagating || equal) alloc");
65 #endif
67 using V4
68 = std::vector<bool, PropAllocator<bool, std::false_type, std::true_type>>;
69 static_assert(std::is_nothrow_constructible<V4, V4::allocator_type>::value,
70 "nothrow constructible with allocator argument");
71 static_assert(std::is_nothrow_move_constructible<V4>::value,
72 "unconditionally nothrow move constructible");
73 static_assert(std::is_nothrow_move_assignable<V4>::value,
74 "nothrow move assignment with propagating alloc");
75 static_assert(std::__is_nothrow_swappable<V4>::value,
76 "nothrow swap with always-equal alloc");
78 using V5
79 = std::vector<bool, PropAllocator<bool, std::true_type, std::false_type>>;
80 static_assert(std::is_nothrow_constructible<V5, V5::allocator_type>::value,
81 "nothrow constructible with allocator argument");
82 static_assert(std::is_nothrow_move_constructible<V5>::value,
83 "unconditionally nothrow move constructible");
84 static_assert(std::is_nothrow_move_assignable<V5>::value,
85 "nothrow move assignment with always-equal alloc");
86 static_assert(std::__is_nothrow_swappable<V5>::value,
87 "nothrow swap with always-equal alloc");