bool.pass.cpp 773 B

12345678910111213141516171819202122232425262728293031
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // UNSUPPORTED: c++98, c++03, c++11
  10. // <optional>
  11. // constexpr explicit optional<T>::operator bool() const noexcept;
  12. #include <experimental/optional>
  13. #include <type_traits>
  14. #include <cassert>
  15. int main()
  16. {
  17. using std::experimental::optional;
  18. {
  19. constexpr optional<int> opt;
  20. static_assert(!opt, "");
  21. }
  22. {
  23. constexpr optional<int> opt(0);
  24. static_assert(opt, "");
  25. }
  26. }