bad_variant_access.pass.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // UNSUPPORTED: c++98, c++03, c++11, c++14
  10. // XFAIL: dylib-has-no-bad_variant_access
  11. // <variant>
  12. /*
  13. class bad_variant_access : public exception {
  14. public:
  15. bad_variant_access() noexcept;
  16. virtual const char* what() const noexcept;
  17. };
  18. */
  19. #include <cassert>
  20. #include <exception>
  21. #include <type_traits>
  22. #include <variant>
  23. #include "test_macros.h"
  24. int main(int, char**) {
  25. static_assert(std::is_base_of<std::exception, std::bad_variant_access>::value,
  26. "");
  27. static_assert(noexcept(std::bad_variant_access{}), "must be noexcept");
  28. static_assert(noexcept(std::bad_variant_access{}.what()), "must be noexcept");
  29. std::bad_variant_access ex;
  30. assert(ex.what());
  31. return 0;
  32. }