value_const.fail.cpp 789 B

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