xref: /llvm-project/libcxx/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp (revision 31cbe0f240f660f15602c96b787c58a26f17e179)
15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
8*31cbe0f2SLouis Dionne // UNSUPPORTED: c++03
95a83710eSEric Fiselier 
105a83710eSEric Fiselier // <vector>
115a83710eSEric Fiselier 
125a83710eSEric Fiselier // vector<bool>()
135a83710eSEric Fiselier //        noexcept(is_nothrow_default_constructible<allocator_type>::value);
145a83710eSEric Fiselier 
155a83710eSEric Fiselier // This tests a conforming extension
16655fb4a7SMarshall Clow // For vector<>, this was added to the standard by N4258,
17655fb4a7SMarshall Clow //   but vector<bool> was not changed.
185a83710eSEric Fiselier 
19f2f2a639SEric Fiselier 
205a83710eSEric Fiselier #include <vector>
215a83710eSEric Fiselier #include <cassert>
225a83710eSEric Fiselier 
23a9fb19d3SEric Fiselier #include "test_macros.h"
245a83710eSEric Fiselier #include "test_allocator.h"
255a83710eSEric Fiselier 
265a83710eSEric Fiselier template <class T>
275a83710eSEric Fiselier struct some_alloc
285a83710eSEric Fiselier {
295a83710eSEric Fiselier     typedef T value_type;
305a83710eSEric Fiselier     some_alloc(const some_alloc&);
315a83710eSEric Fiselier };
325a83710eSEric Fiselier 
main(int,char **)332df59c50SJF Bastien int main(int, char**)
345a83710eSEric Fiselier {
3503fe6e2dSStephan T. Lavavej #if defined(_LIBCPP_VERSION)
365a83710eSEric Fiselier     {
375a83710eSEric Fiselier         typedef std::vector<bool> C;
3803fe6e2dSStephan T. Lavavej         static_assert(std::is_nothrow_default_constructible<C>::value, "");
395a83710eSEric Fiselier     }
405a83710eSEric Fiselier     {
415a83710eSEric Fiselier         typedef std::vector<bool, test_allocator<bool>> C;
4203fe6e2dSStephan T. Lavavej         static_assert(std::is_nothrow_default_constructible<C>::value, "");
435a83710eSEric Fiselier     }
445a83710eSEric Fiselier     {
455a83710eSEric Fiselier         typedef std::vector<bool, other_allocator<bool>> C;
465a83710eSEric Fiselier         static_assert(!std::is_nothrow_default_constructible<C>::value, "");
475a83710eSEric Fiselier     }
485a83710eSEric Fiselier     {
495a83710eSEric Fiselier         typedef std::vector<bool, some_alloc<bool>> C;
505a83710eSEric Fiselier         static_assert(!std::is_nothrow_default_constructible<C>::value, "");
515a83710eSEric Fiselier     }
52655fb4a7SMarshall Clow #endif // _LIBCPP_VERSION
532df59c50SJF Bastien 
542df59c50SJF Bastien   return 0;
555a83710eSEric Fiselier }
56