bool.pass.cpp 800 B

123456789101112131415161718192021222324252627282930313233
  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. // <system_error>
  9. // class error_code
  10. // explicit operator bool() const;
  11. #include <system_error>
  12. #include <string>
  13. #include <cassert>
  14. #include "test_macros.h"
  15. int main(int, char**)
  16. {
  17. {
  18. const std::error_code ec(6, std::generic_category());
  19. assert(static_cast<bool>(ec));
  20. }
  21. {
  22. const std::error_code ec(0, std::generic_category());
  23. assert(!static_cast<bool>(ec));
  24. }
  25. return 0;
  26. }