default_noexcept.pass.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // UNSUPPORTED: c++98, c++03
  9. // <vector>
  10. // vector<bool>()
  11. // noexcept(is_nothrow_default_constructible<allocator_type>::value);
  12. // This tests a conforming extension
  13. // For vector<>, this was added to the standard by N4258,
  14. // but vector<bool> was not changed.
  15. #include <vector>
  16. #include <cassert>
  17. #include "test_macros.h"
  18. #include "test_allocator.h"
  19. template <class T>
  20. struct some_alloc
  21. {
  22. typedef T value_type;
  23. some_alloc(const some_alloc&);
  24. };
  25. int main(int, char**)
  26. {
  27. #if defined(_LIBCPP_VERSION)
  28. {
  29. typedef std::vector<bool> C;
  30. static_assert(std::is_nothrow_default_constructible<C>::value, "");
  31. }
  32. {
  33. typedef std::vector<bool, test_allocator<bool>> C;
  34. static_assert(std::is_nothrow_default_constructible<C>::value, "");
  35. }
  36. {
  37. typedef std::vector<bool, other_allocator<bool>> C;
  38. static_assert(!std::is_nothrow_default_constructible<C>::value, "");
  39. }
  40. {
  41. typedef std::vector<bool, some_alloc<bool>> C;
  42. static_assert(!std::is_nothrow_default_constructible<C>::value, "");
  43. }
  44. #endif // _LIBCPP_VERSION
  45. return 0;
  46. }