54 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8// UNSUPPORTED: c++039 10// <vector>11 12// vector<bool>()13// noexcept(is_nothrow_default_constructible<allocator_type>::value);14 15// This tests a conforming extension16// For vector<>, this was added to the standard by N4258,17// but vector<bool> was not changed.18 19#include <cassert>20#include <vector>21#include <type_traits>22 23#include "test_macros.h"24#include "test_allocator.h"25 26template <class T>27struct some_alloc {28 typedef T value_type;29 some_alloc(const some_alloc&);30};31 32int main(int, char**) {33#if defined(_LIBCPP_VERSION)34 {35 typedef std::vector<bool> C;36 static_assert(std::is_nothrow_default_constructible<C>::value, "");37 }38 {39 typedef std::vector<bool, test_allocator<bool>> C;40 static_assert(std::is_nothrow_default_constructible<C>::value, "");41 }42 {43 typedef std::vector<bool, other_allocator<bool>> C;44 static_assert(!std::is_nothrow_default_constructible<C>::value, "");45 }46 {47 typedef std::vector<bool, some_alloc<bool>> C;48 static_assert(!std::is_nothrow_default_constructible<C>::value, "");49 }50#endif // _LIBCPP_VERSION51 52 return 0;53}54