xref: /llvm-project/libcxx/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp (revision f2f2a6395fad5bd49a573fdf2b20072735d496f7)
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <vector>
11 
12 // vector<bool>()
13 //        noexcept(is_nothrow_default_constructible<allocator_type>::value);
14 
15 // This tests a conforming extension
16 
17 // UNSUPPORTED: c++98, c++03
18 
19 #include <vector>
20 #include <cassert>
21 
22 #include "test_allocator.h"
23 
24 template <class T>
25 struct some_alloc
26 {
27     typedef T value_type;
28     some_alloc(const some_alloc&);
29 };
30 
31 int main()
32 {
33     {
34         typedef std::vector<bool> C;
35         static_assert(std::is_nothrow_default_constructible<C>::value, "");
36     }
37     {
38         typedef std::vector<bool, test_allocator<bool>> C;
39         static_assert(std::is_nothrow_default_constructible<C>::value, "");
40     }
41     {
42         typedef std::vector<bool, other_allocator<bool>> C;
43         static_assert(!std::is_nothrow_default_constructible<C>::value, "");
44     }
45     {
46         typedef std::vector<bool, some_alloc<bool>> C;
47         static_assert(!std::is_nothrow_default_constructible<C>::value, "");
48     }
49 }
50