value_const.fail.cpp 752 B

123456789101112131415161718192021222324252627282930313233
  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, c++14
  10. // <optional>
  11. // constexpr const T& optional<T>::value() const &;
  12. #include <optional>
  13. #include <type_traits>
  14. #include <cassert>
  15. using std::optional;
  16. struct X
  17. {
  18. constexpr int test() const {return 3;}
  19. int test() {return 4;}
  20. };
  21. int main()
  22. {
  23. {
  24. constexpr optional<X> opt;
  25. static_assert(opt.value().test() == 3, "");
  26. }
  27. }